How to use core-util-is - 10 common examples

To help you get started, we’ve selected a few core-util-is 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 nodejs / readable-stream / test / common / heap.js View on Github external
var _loop = function _loop() {
              var expectedEdge = _step2.value;
              var check = typeof expectedEdge === 'function' ? expectedEdge : function (edge) {
                return isEdge(edge, expectedEdge);
              };
              var hasChild = rootNodes.some(function (node) {
                return node.outgoingEdges.some(check);
              }); // Don't use assert with a custom message here. Otherwise the
              // inspection in the message is done eagerly and wastes a lot of CPU
              // time.

              if (!hasChild) {
                throw new Error('expected to find child ' + "".concat(util.inspect(expectedEdge), " in ").concat(inspectNode(rootNodes)));
              }
            };
github nodejs / readable-stream / test / common / index.js View on Github external
function innerFn(error) {
    if (arguments.length !== 1) {
      // Do not use `assert.strictEqual()` to prevent `util.inspect` from
      // always being called.
      assert.fail("Expected one argument, got ".concat(util.inspect(arguments)));
    }

    var descriptor = Object.getOwnPropertyDescriptor(error, 'message'); // The error message should be non-enumerable

    assert.strictEqual(descriptor.enumerable, false);
    var innerSettings = settings;

    if ('type' in settings) {
      var type = settings.type;

      if (type !== Error && !Error.isPrototypeOf(type)) {
        throw new TypeError('`settings.type` must inherit from `Error`');
      }

      var _constructor = error.constructor;
github nodejs / readable-stream / test / common / heap.js View on Github external
var _loop2 = function _loop2() {
              var expectedEdge = _step4.value;
              var check = typeof expectedEdge === 'function' ? expectedEdge : function (edge) {
                return isEdge(edge, expectedEdge);
              }; // Don't use assert with a custom message here. Otherwise the
              // inspection in the message is done eagerly and wastes a lot of CPU
              // time.

              var hasChild = rootNodes.some(function (node) {
                return node.edges.some(check);
              });

              if (!hasChild) {
                throw new Error('expected to find child ' + "".concat(util.inspect(expectedEdge), " in ").concat(inspectNode(rootNodes)));
              }
            };
github nodejs / readable-stream / test / common / index.js View on Github external
process.on('exit', function () {
    // iterate through handles to make sure nothing crashes
    for (var k in initHandles) {
      util.inspect(initHandles[k]);
    }
  });
  var _queueDestroyAsyncId = async_wrap.queueDestroyAsyncId;
github nodejs / string_decoder / test / common / index.js View on Github external
process.on('exit', function () {
    // itterate through handles to make sure nothing crashes
    for (var k in initHandles) {
      util.inspect(initHandles[k]);
    }
  });
github pablomarle / networkmaps / node_modules / readable-stream / lib / _stream_transform.js View on Github external
// However, even in such a pathological case, only a single written chunk
// would be consumed, and then the rest would wait (un-transformed) until
// the results of the previous transformed chunk were consumed.

'use strict';

module.exports = Transform;

var Duplex = require('./_stream_duplex');

/**/
var util = require('core-util-is');
util.inherits = require('inherits');
/**/

util.inherits(Transform, Duplex);

function afterTransform(er, data) {
  var ts = this._transformState;
  ts.transforming = false;

  var cb = ts.writecb;

  if (!cb) {
    return this.emit('error', new Error('write callback called multiple times'));
  }

  ts.writechunk = null;
  ts.writecb = null;

  if (data != null) // single equals check for both `null` and `undefined`
    this.push(data);
github strongloop / angular-live-set / dist / live-set.js View on Github external
state.needReadable = true;
    n = 0;
  }

  state.length -= n;

  // If we have nothing in the buffer, then we want to know
  // as soon as we *do* get something into the buffer.
  if (state.length === 0 && !state.ended)
    state.needReadable = true;

  // If we tried to read() past the EOF, then emit end on the next tick.
  if (nOrig !== n && state.ended && state.length === 0)
    endReadable(this);

  if (!util.isNull(ret))
    this.emit('data', ret);

  return ret;
};
github liquidg3 / altair / node_modules / npm / node_modules / npm-install-checks / node_modules / npmlog / node_modules / are-we-there-yet / node_modules / readable-stream / lib / _stream_readable.js View on Github external
state.needReadable = true;
    n = 0;
  }

  state.length -= n;

  // If we have nothing in the buffer, then we want to know
  // as soon as we *do* get something into the buffer.
  if (state.length === 0 && !state.ended)
    state.needReadable = true;

  // If we tried to read() past the EOF, then emit end on the next tick.
  if (nOrig !== n && state.ended && state.length === 0)
    endReadable(this);

  if (!util.isNull(ret))
    this.emit('data', ret);

  return ret;
};
github Andyliwr / FE-learning-load / task08 / lidikang / styles / node_modules / readable-stream / lib / _stream_readable.js View on Github external
state.needReadable = true;
    n = 0;
  }

  state.length -= n;

  // If we have nothing in the buffer, then we want to know
  // as soon as we *do* get something into the buffer.
  if (state.length === 0 && !state.ended)
    state.needReadable = true;

  // If we tried to read() past the EOF, then emit end on the next tick.
  if (nOrig !== n && state.ended && state.length === 0)
    endReadable(this);

  if (!util.isNull(ret))
    this.emit('data', ret);

  return ret;
};
github webtorrent / webtorrent / lib / bittorrent-dht / index.js View on Github external
if (!message.t || (bops.to(message.t) !== self.requestId.toString())) {
    console.log('wrong message requestId: ', bops.to(message.t), self.requestId.toString(), host, port)
    return
  }

  // Mark that we've seen this node (the one we received data from)
  self.nodes[addr] = true

  var r = message && message.r

  if (r && bops.is(r.nodes)) {
    // console.log('got nodes')
    parseNodeInfo(r.nodes).forEach(self._handleNode.bind(self))
  }
  if (r && is.isArray(r.values)) {
    // console.log('got peers')
    parsePeerInfo(r.values).forEach(self._handlePeer.bind(self))
  }
}