How to use the bindings.convert function in bindings

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

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nfroidure / ttf2woff2 / tests / tests.mocha.js View on Github external
it('should work from the native build', function(done) {
    var ttf2woff2 = require('bindings')('addon.node').convert;
    var inputContent = fs.readFileSync(__dirname + '/expected/iconsfont.ttf');
    var outputContent = ttf2woff2(inputContent);

    assert.equal(outputContent.length, 1072);
    assert.equal(outputContent[1071], 0);
    assert.deepEqual(
      outputContent,
      fs.readFileSync(__dirname + '/expected/iconsfont.woff2')
    );
    done();
  });
github nfroidure / ttf2woff2 / src / index.js View on Github external
'use strict';

try {
  module.exports = require('bindings')('addon.node').convert;
} catch (err) {
  module.exports = require('../jssrc/index.js');
}