example-d3/webworker.js
/**
 * The main `bindings()` function loads the compiled bindings for a given module.
 * It uses V8's Error API to determine the parent filename that this function is
 * being invoked from, which is then used to find the root directory.
 */
The main `bindings()` function loads the compiled bindings for a given module.
It uses V8's Error API to determine the parent filename that this function is
being invoked from, which is then used to find the root directory.
The main ` bindings () ` function loads the compiled bindings for a given module . It uses V8 ' s Error API to determine the parent filename that this function is being invoked from which is then used to find the root directory .
function bindings (opts) {
  if (typeof opts == 'string') {
    opts = { bindings: opts }
  } else if (!opts) {
    opts = {}
  }
  opts.__proto__ = defaults
  if (!opts.module_root) {
    opts.module_root = exports.getRoot(exports.getFileName())
  }
  if (path.extname(opts.bindings) != '.node') {
    opts.bindings += '.node'
  }
  var tries = []
    , i = 0
    , l = opts.try.length
    , n
    , b
    , err
  for (; i<l; i++) {
    n = join.apply(null, opts.try[i].map(function (p) {
      return opts[p] || p
    }))
    tries.push(n)
    try {
      b = opts.path ? require.resolve(n) : require(n)
      if (!opts.path) {
        b.path = n
      }
      return b
    } catch (e) {
      if (!/not find/i.test(e.message)) {
        throw e
      }
    }
  }
  err = new Error('Could not locate the bindings file. Tried:\n'
    + tries.map(function (a) { return opts.arrow + a }).join('\n'))
  err.tries = tries
}
function bindings ( opts ) { if ( typeof opts == 'string' ) { opts = { bindings : opts } } else if ( ! opts ) { opts = { } } opts . __proto__ = defaults if ( ! opts . module_root ) { opts . module_root = exports . getRoot ( exports . getFileName ( ) ) } if ( path . extname ( opts . bindings ) != '.node' ) { opts . bindings += '.node' } var tries = [ ] , i = 0 , l = opts . try . length , n , b , err for ( ; i < l ; i ++ ) { n = join . apply ( null , opts . try [ i ] . map ( function ( p ) { return opts [ p ] || p } ) ) tries . push ( n ) try { b = opts . path ? require . resolve ( n ) : require ( n ) if ( ! opts . path ) { b . path = n } return b } catch ( e ) { if ( ! / not find / i . test ( e . message ) ) { throw e } } } err = new Error ( 'Could not locate the bindings file. Tried:\n' + tries . map ( function ( a ) { return opts . arrow + a } ) . join ( '\n' ) ) err . tries = tries }
The main `bindings()` function loads the compiled bindings for a given module.
The main ` bindings () ` function loads the compiled bindings for a given module .
// Argument surgery // Get the module root // Ensure the given bindings name ends with .node //throw err