How to use bindings - 10 common examples

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 noobaa / noobaa-core / frontend / src / app / main.js View on Github external
// Enable knockout 3.4 deferred updates.
    ko.options.deferUpdates = true;

    // Setup validation policy.
    ko.validation.init({
        errorMessageClass: 'val-msg',
        decorateInputElement: true,
        errorElementClass: 'invalid',
        errorsAsTitle: false,
        messagesOnModified: true,
        writeInputAttributes: true
    });

    // Register custom extenders, bindings, components and validation rules.
    registerExtenders(ko);
    registerBindings(ko);
    registerValidationRules(ko);
    registerComponents(ko, injectedServices);
}
github serialport / node-serialport / packages / bindings / lib / win32.ts View on Github external
// tslint:disable:readonly-keyword
import bindings from 'bindings'
import debug from 'debug'
import { promisify } from './util'
import { AbstractBinding, PortInfo, OpenOptions, ConstructorOptions, LocalState, RemoteState, SetOptions } from '@serialport/binding-abstract'
import { serialNumParser } from './win32-sn-parser'

const logger = debug('serialport/bindings/WindowsBinding')
const windowsBinding = bindings('bindings.node')
const closeAsync = promisify(windowsBinding.close) as (descriptor: number) => Promise
const drainAsync = promisify(windowsBinding.drain) as (descriptor: number) => Promise
const flushAsync = promisify(windowsBinding.flush) as (descriptor: number) => Promise
const getRemoteStateAsync = promisify(windowsBinding.getRemoteState) as (descriptor: number) => Promise
const openAsync = promisify(windowsBinding.open) as (opt: LocalState) => Promise
const setLocalStateAsync = promisify(windowsBinding.setLocalState) as (descriptor: number, opts: SetOptions) => Promise
const listAsync = promisify(windowsBinding.list) as () => Promise>
const readAsync = promisify(windowsBinding.read) as (descriptor: number, buffer: Buffer, offset: number, length: number) => Promise
const writeAsync = promisify(windowsBinding.write) as (descriptor: number, buffer: Buffer) => Promise

/**
 * The Windows binding layer
 */
export class WindowsBinding implements AbstractBinding {
  static async list() {
    const ports = await listAsync()
github intel / iotivity-node / grunt-build / tasks / options / iot-js-api.js View on Github external
module.exports = function( grunt ) {

var assignIn = require( "lodash.assignin" );
var path = require( "path" );
var ocfRunner = require( "iot-js-api" );
var results = require( "../../../tests/getresult" );

var packageRoot = path.join( require( "bindings" ).getRoot( __filename ) );
var preamblePath = path.join( packageRoot, "tests", "preamble" );
var generateSpawn = function( spawnFinal ) {
	return function( interpreter, commandLine ) {
		var preambleCommandLine;

		commandLine[ 2 ] = grunt.option( "ci" ) ?
			path.dirname( require.resolve( "iotivity-node" ) ) :
			packageRoot;

		preambleCommandLine = commandLine.slice();

		// argv[ 4 ] for the preamble means to clobber or not, not secure or not. Let's
		// make sure we clobber any previous test ACLs.
		preambleCommandLine[ 3 ] = false;

		require( preamblePath ).apply( this, preambleCommandLine );
github tessel / t2-cli / lib / tessel / deployment / javascript.js View on Github external
var binaries = glob.files(globRoot, patterns).reduce((bins, globPath) => {
      // Gather information about each found module
      var resolved = true;
      var modulePath = bindings.getRoot(globPath);
      var packageJson = require(path.join(globRoot, modulePath, 'package.json'));
      var binName = path.basename(globPath);
      var buildPath = path.normalize(globPath.replace(path.join(modulePath), '').replace(binName, ''));
      var buildType = (function() {
        var matches = buildPath.match(buildexp);
        if (matches && matches.length) {
          return matches[1];
        }
        return 'Release';
      }());

      // If the compiled module doesn't actually need a binary.node
      // injected into the bundle, then there is nothing to do.
      if (packageJson.tessel && packageJson.tessel.skipBinary) {
        return bins;
      }
github eelcocramer / node-bluetooth-serial-port / lib / device-inquiry.js View on Github external
(function () {
    "use strict";

    // javascript shim that lets our object inherit from EventEmitter
    var DeviceINQ = require('bindings')('BluetoothSerialPort.node').DeviceINQ,
        events = require('events');

    // extend prototype
    function inherits(target, source) {
        var k;

        for (k in source.prototype) {
            target.prototype[k] = source.prototype[k];
        }
    }

    inherits(DeviceINQ, events.EventEmitter);
    exports.DeviceINQ = DeviceINQ;

}());
github mongodb-js / bson-ext / lib / index.js View on Github external
var BSON = require('bindings')('bson').BSON;
var jsBson = require('bson');

// BSON MAX VALUES
BSON.BSON_INT32_MAX = 0x7FFFFFFF;
BSON.BSON_INT32_MIN = -0x80000000;

BSON.BSON_INT64_MAX = Math.pow(2, 63) - 1;
BSON.BSON_INT64_MIN = -Math.pow(2, 63);

// JS MAX PRECISE VALUES
BSON.JS_INT_MAX = 0x20000000000000;  // Any integer up to 2^53 can be precisely represented by a double.
BSON.JS_INT_MIN = -0x20000000000000;  // Any integer down to -2^53 can be precisely represented by a double.

// Decorate BSON with types from js-bson
[
  'Binary',
github yodaos-project / yoda.js / deprecated / bluetooth / index.js View on Github external
'use strict';

const property = require('@rokid/property');
const logger = require('@rokid/logger')('bluetooth');
const context = require('@rokid/context');
const BluetoothWrap = require('bindings')('bluetooth').BluetoothWrap;
const EventEmitter = require('events').EventEmitter;

const id = property.serialno ? property.serialno.slice(-6) : 'xxxxxx';
const name = context.deviceConfig.namePrefix + id;
let handle;

const BT_EVENTS = {
  // a2dp source events
  A2DP_SOURCE_OPEN: 1,
  A2DP_SOURCE_CLOSE: 2,
  A2DP_SOURCE_START: 3,
  A2DP_SOURCE_STOP: 4,
  // a2dp sink events
  A2DP_SINK_OPEN: 21,
  A2DP_SINK_CLOSE: 22,
  A2DP_SINK_STREAM_OPEN: 23,
github thomaschaaf / node-ftdi / ftdi.js View on Github external
var FTDIDriver = require('bindings')('ftdi.node').FtdiDriver;
var FTDIDevice = require('bindings')('ftdi.node').FtdiDevice;

var ftdiBinding;
var sys = require('sys'),
events = require('events');

// var deviceSettings = {
//   vid: 0x27f4,
//   pid: 0x0203
// };
var deviceSettings = {
  vid: 0x18d9,
  pid: 0x01a0
};

var connectionSettings =
{
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 serialport / node-serialport / packages / bindings / lib / poller.js View on Github external
const debug = require('debug')
const logger = debug('serialport/bindings/poller')
const EventEmitter = require('events')
const PollerBindings = require('bindings')('bindings.node').Poller

const EVENTS = {
  UV_READABLE: 0b0001,
  UV_WRITABLE: 0b0010,
  UV_DISCONNECT: 0b0100,
}

function handleEvent(error, eventFlag) {
  if (error) {
    logger('error', error)
    this.emit('readable', error)
    this.emit('writable', error)
    this.emit('disconnect', error)
    return
  }
  if (eventFlag & EVENTS.UV_READABLE) {