How to use utils - 10 common examples

To help you get started, we’ve selected a few utils examples, based on popular ways it is used in public projects.

github mozilla-b2g / gaia / apps / keyboard / build / build.js View on Github external
KeyboardAppBuilder.prototype.generateLayoutsJSON = function() {
  // Write a dictionary list file into keyboard/js/settings/
  // This file is noly used in keyboard settings page.
  // (That's why we annotate latin.js too.)
  var configFileDesc = utils.getFile(
    this.distDir.path, 'js', 'settings', 'layouts.json');

  var layouts = this.layoutConfigurator.getLayoutsJSON();

  utils.writeContent(
    configFileDesc, JSON.stringify(layouts, null, 2));
};
github galaxyproject / galaxy-beta1 / test / casperjs / api-configuration-tests.js View on Github external
function hasKeys( object, keysArray ){
    if( !utils.isObject( object ) ){ return false; }
    for( var i=0; i<keysArray.length; i += 1 ){
        if( !object.hasOwnProperty( keysArray[i] ) ){
            spaceghost.debug( 'key not found: ' + keysArray[i] );
            return false;
        }
    }
    return true;
}
github HuddleEng / PhantomXHR / CasperJs / modules / injector.js View on Github external
this.process = function process(values) {
        var fnObj = this.extract(this.fn);
        if (!utils.isObject(fnObj)) {
            throw new CasperError("Unable to process function " + this.fn.toString());
        }
        var inject = this.getArgsInjectionString(fnObj.args, values);
        var newFn = new Function([inject, fnObj.body].join('\n'));
        newFn.name = fnObj.name || '';
        return newFn;
    };
github casperjs / casperjs / modules / injector.js View on Github external
this.process = function process(values) {
        var fnObj = this.extract(this.fn);
        if (!utils.isObject(fnObj)) {
            throw new CasperError("Unable to process function " + this.fn.toString());
        }
        var inject = this.getArgsInjectionString(fnObj.args, values);
        var newFn = new Function([inject, fnObj.body].join('\n'));
        newFn.name = fnObj.name || '';
        return newFn;
    };
github liuxx001 / bird-front / src / components / Form / BirdButton.js View on Github external
refreshToken() {
    request({
      url: config.api.getOperationToken,
      method: 'GET'
    }).then(token => {
      this.setState({ token: token })
    })
  }
github liuxx001 / bird-front / src / components / File / FileIcon.js View on Github external
initFileName(props) {
    if (util.string.isEmpty(props.url) || !props.queryFileName) {
      this.setState({ fileName: props.url })
    } else {
      request({
        url: config.api.getFileName + this.props.url,
        method: 'GET'
      }).then(fileName => {
        this.setState({ fileName: fileName })
      })
    }
  }
github liuxx001 / bird-front / src / components / Form / BirdCascader.js View on Github external
componentDidMount() {
    if (this.props.data.length > 0) {
      this.initData(this.props.data);
    } else if (this.props.url) {
      request({
        url: this.props.url,
        method: 'GET'
      }).then(data => {
        this.initData(data);
      })
    }
  }
github Hopding / pdf-lib / src / core / pdf-objects / PDFRawStream.ts View on Github external
copyBytesInto = (buffer: Uint8Array): Uint8Array => {
    this.validateDictionary();
    let remaining = this.dictionary.copyBytesInto(buffer);
    remaining = addStringToBuffer('\nstream\n', remaining);

    remaining.set(this.content, 0);
    remaining = remaining.subarray(this.content.length);

    remaining = addStringToBuffer('\nendstream', remaining);
    return remaining;
  };
}
github Hopding / pdf-lib / src / core / pdf-structures / PDFObjectStream.ts View on Github external
private copyContentBytesInto = (buffer: Uint8Array): Uint8Array => {
    const remaining = addStringToBuffer(this.leadingIntegerPairsStr(), buffer);
    return this.objects.reduce(
      (remBytes, obj) =>
        addStringToBuffer('\n', obj.pdfObject.copyBytesInto(remBytes)),
      remaining,
    );
  };
github Hopding / pdf-lib / src / core / pdf-operators / text / PDFTextObject.ts View on Github external
copyBytesInto = (buffer: Uint8Array): Uint8Array => {
    let remaining = addStringToBuffer('BT\n', buffer);

    remaining = this.operators
      .filter(Boolean)
      .reduce(
        (remBytes: Uint8Array, op: PDFOperator) => op.copyBytesInto(remBytes),
        remaining,
      );

    remaining = addStringToBuffer('ET\n', remaining);
    return remaining;
  };
}

utils

Fast, generic JavaScript/node.js utility functions.

MIT
Latest version published 7 years ago

Package Health Score

44 / 100
Full package analysis

Similar packages