當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript es6-symbol.default函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。