• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript es6-symbol.default函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中es6-symbol.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了default函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: block

var Symbol = require('es6-symbol');

import {InSystemProgramming} from './InSystemProgramming';
import * as Utilities from './Utilities';
import {MemoryBlock} from './MemoryBlock';
import {RAMAddress} from './RAMAddress';
import {ROMBlock} from './ROMBlock';

const _blockSym = Symbol();

export class ROMWriter implements MemoryBlock {

  set block(block: ROMBlock) { this[_blockSym] = block; }
  get block(): ROMBlock { return this[_blockSym]; }

  get address(): number { return this.block.address; }
  get sector(): number { return this.block.sector; }
  get length(): number { return this.block.length; }

  constructor(private isp: InSystemProgramming, addr?: number, size?: number) {
    if ((addr !== void 0) && size) {
      this[_blockSym] = ROMBlock.fromAddress(addr, size);
    }
  }

  eraseBlock(): Promise<ROMWriter> {
    const endSect = Utilities.addressToSector(this.address + this.length - 1);
    return this.isp.unlock()
      .then(() => this.isp.sendCommand(`P ${this.sector} ${endSect}`))
      .then(() => this.isp.sendCommand(`E ${this.sector} ${endSect}`))
      .then(() => this);
开发者ID:sergezloto,项目名称:flashmagic.js,代码行数:31,代码来源:ROMWriter.ts


示例2: checksum

var Symbol = require('es6-symbol');

const _checksumSym = Symbol();

export class UUEncoder {

  constructor() {
    this[_checksumSym] = 0;
  }

  get checksum(): number {
    return this[_checksumSym];
  }

  reset(): void {
    this[_checksumSym] = 0;
  }

  encode(data: Buffer | Uint8Array, offset: number, length: number): string {
    let out = encodeSingle(length);
    let sum = 0;
    const n = ~~(length / 3) * 3;
    const m = n + offset;
    let i = offset;
    while (i < m) {
      let a = data[i++];
      let b = data[i++];
      let c = data[i++];
      out += encodeTriple(a, b, c);
      sum += a + b + c;
    }
开发者ID:sergezloto,项目名称:flashmagic.js,代码行数:31,代码来源:UUEncoder.ts


示例3: address

var Symbol = require('es6-symbol');

import {InSystemProgramming} from './InSystemProgramming';
import * as Utilities from './Utilities';
import {RAMAddress} from './RAMAddress';
import {ROMAddress} from './ROMAddress';
import {UUEncoder} from './UUEncoder';

const _addressSym = Symbol();

export class RAMWriter {

  set address(address: RAMAddress) { this[_addressSym] = address; }
  get address(): RAMAddress { return this[_addressSym]; }

  constructor(private isp: InSystemProgramming) { }

  writeToRAM(buffer: Buffer): Promise<RAMWriter> {
    let ret: Promise<any> = this.isp.sendCommand(`W ${this.address} ${buffer.length}`)
      .then(() => this.uploadChunk(buffer));
    if (process.env['ISP'] === 'legacy') {
      // XXX our custom bootloader sends a CMD_SUCCESS after every write ;(
      ret = ret.then(() => this.isp.assertSuccess());
    }
    return ret.then(() => {
      this.address = this.address.increment(buffer.length);
      return this;
    });
  }

  private uploadChunk(buffer: Buffer): Promise<void> {
开发者ID:sergezloto,项目名称:flashmagic.js,代码行数:31,代码来源:RAMWriter.ts


示例4: address

var Symbol = require('es6-symbol');

import * as Utilities from './Utilities';
import {MemoryBlock} from './MemoryBlock';
import {ROMAddress} from './ROMAddress';

const _addressSym = Symbol();
const _lengthSym = Symbol();

export class ROMBlock implements MemoryBlock {

  get address(): number { return this[_addressSym].address; }
  get sector(): number { return this[_addressSym].sector; }
  get length(): number { return this[_lengthSym]; }

  constructor(addr: ROMAddress, size: number) {
    let n = addr.address;
    if (size < 0) {
      throw new RangeError(`ROM block size ${size} must be >= 0`);
    }
    let m = n + size - 1;
    if (m > Utilities.MAX_ROM_ADDRESS) {
      throw new RangeError(`ROM block [0x${n.toString(16)}...0x${m.toString(16)}] out of address space`);
    }
    this[_addressSym] = addr;
    this[_lengthSym] = size;
  }

  adjust(diff: number): ROMBlock {
    let size = Math.max(0, this.length - diff);
    return ROMBlock.fromAddress(this.address + diff, size);
开发者ID:sergezloto,项目名称:flashmagic.js,代码行数:31,代码来源:ROMBlock.ts


示例5: BASE

var Symbol = require('es6-symbol');

import * as Utilities from './Utilities';

const _addressSym = Symbol();
const _sectorSym = Symbol();

export class ROMAddress {

  static get BASE() { return 0; }
  static get SIZE() { return Utilities.MAX_ROM_ADDRESS + 1; } // 504 KB

  get address(): number { return this[_addressSym]; }
  get sector(): number { return this[_sectorSym]; }

  constructor(addr: number, sect: number) {
    addr = ~~addr; // toInteger
    sect = ~~sect; // toInteger
    if (addr & 3) {
      throw new RangeError(`ROM address 0x${addr.toString(16)} must be aligned`);
    }
    if (addr < ROMAddress.BASE || addr >= ROMAddress.BASE + ROMAddress.SIZE) {
      throw new RangeError(`ROM address 0x${addr.toString(16)} out of range`);
    }
    if (sect < 0 || sect > Utilities.MAX_SECTOR) {
      throw new RangeError(`ROM sector ${sect} out of range`);
    }
    if (Utilities.addressToSector(addr) !== sect) {
      throw new RangeError(`ROM address 0x${addr.toString(16)} / sector ${sect} mismatch`);
    }
    this[_addressSym] = addr;
开发者ID:sergezloto,项目名称:flashmagic.js,代码行数:31,代码来源:ROMAddress.ts



注:本文中的es6-symbol.default函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript util.member函数代码示例发布时间:2022-05-25
下一篇:
TypeScript es6-sleep.promise函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap