How to use the util.isNumber function in util

To help you get started, we’ve selected a few util 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 UWNetworksLab / uProxy-p2p / src / lib / build-tools / alias / net.js View on Github external
function Socket(options) {
  if (!(this instanceof Socket)) return new Socket(options);

  this._connecting = false;
  this._hadError = false;
  this._handle = null;
  this._host = null;

  if (util.isNumber(options))
    options = { fd: options }; // Legacy interface.
  else if (util.isUndefined(options))
    options = {};

  stream.Duplex.call(this, options);

  if (options.handle) {
    this._handle = options.handle; // private
  } else if (!util.isUndefined(options.fd)) {
    this._handle = createHandle(options.fd);
    this._handle.open(options.fd);
    this.readable = options.readable !== false;
    this.writable = options.writable !== false;
  } else {
    // these will be set once there is a connection
    this.readable = this.writable = false;
github yodaos-project / ShadowNode / src / js / pwm.js View on Github external
'Bad configuration - pin is mandatory and should be Number');
      } else {
        self._configuration.pin = configuration.pin;
      }
    } else {
      throw new TypeError('Bad arguments - configuration should be Object');
    }

    // validate configuration
    var dutyCycle = configuration.dutyCycle;
    var period = configuration.period;
    if (!util.isNumber(period) && util.isNumber(configuration.frequency)) {
      period = 1.0 / configuration.frequency;
    }

    if (util.isNumber(dutyCycle) && dutyCycle >= 0.0 && dutyCycle <= 1.0 &&
      util.isNumber(period) && util.isFinite(period) && period > 0) {
      self._configuration.dutyCycle = dutyCycle;
      self._configuration.period = period;
    }

    _binding = new native(self._configuration, function(err) {
      util.isFunction(callback) && callback.call(self, err);
    });

    process.on('exit', (function(self) {
      return function() {
        if (_binding !== null) {
          self.closeSync();
        }
      };
    })(this));
github marklogic / marklogic-data-hub / web / src / main / ui / app / components / flows-new / models / flow.model.ts View on Github external
static fromJSON(json) {

    const result = new Flow();

    if (json.id) {
      result.id = json.id;
    }
    if (json.name) {
      result.name = json.name;
    }
    if (json.description) {
      result.description = json.description;
    }
    if (json.batchSize && isNumber(parseInt(json.batchSize))) {
      result.batchSize = json.batchSize;
    }
    if (json.threadCount && isNumber(parseInt(json.threadCount))) {
      result.threadCount = json.threadCount;
    }
    if (json.options) {
      result.options = json.options;
    }
    if (json.steps) {
      result.steps = json.steps;
    }
    if (json.jobs) {
      result.jobs = json.jobs;
    }
    if (json.latestJob) {
      result.latestJob = json.latestJob;
github ShieldBattery / ShieldBattery / node_modules / browserify-middleware / node_modules / browserify / node_modules / browser-builtins / builtin / querystring.js View on Github external
var stringifyPrimitive = function(v) {
  if (util.isString(v))
    return v;
  if (util.isBoolean(v))
    return v ? 'true' : 'false';
  if (util.isNumber(v))
    return isFinite(v) ? v : '';
  return '';
};
github getheimdall / heimdall / heimdall-frontend / src / utils / OrderInterceptorsUtisl.js View on Github external
export function changeOrder(orderDrag, newOrder, interceptors) {

    const allInterceptors = JSON.parse(JSON.stringify(interceptors))

    if (orderIsWrong(allInterceptors)){
        updateOrder(allInterceptors)
    }

    let newIndexInterceptor = 0
    let indexInterceptor = 0

    if (isNumber(newOrder)) {
        newIndexInterceptor = allInterceptors.findIndex(element => element.id === newOrder)
    } else {
        newIndexInterceptor = allInterceptors.findIndex(element => element.uuid === newOrder)
    }
    
    if (isNumber(orderDrag)) {
        indexInterceptor = allInterceptors.findIndex(element => element.id === orderDrag)
    } else {
        indexInterceptor = allInterceptors.findIndex(element => element.uuid === orderDrag)
    }

    let changedInterceptors = []

    allInterceptors[indexInterceptor].order = allInterceptors[newIndexInterceptor].order
    changedInterceptors.push(allInterceptors[indexInterceptor])
github pikax / swgoh / dist / index.cjs.js View on Github external
Swgoh.prototype.guild = function (opts) {
        var uri;
        if (typeof opts === "string") {
            var m = opts.match(/\d+/);
            if (!m) {
                throw new Error("Error: \"" + opts + "\" is not a valid guild url");
            }
            uri = url.resolve(swgohgg, opts);
        }
        else {
            var id = opts.id;
            if (isNaN(id) || !util.isNumber(id)) {
                throw new Error("Error: Unable to parse guild id from \"" + opts + "\"");
            }
            var name = opts.name;
            if (!name || name === '') {
                throw new Error("Error: Unable to parse guild name from \"" + opts + "\"");
            }
            uri = url.resolve(swgohgg, "/g/" + id + "/" + name + "/");
        }
        return this.getCheerio(uri).then(parseGuild);
    };
    Swgoh.prototype.units = function (opts) {
github kpi-wdc / dj / dj-libs / script / impl / table / order.js View on Github external
throw new OrderImplError("Incompatible context type: '" + state.head.type + "'.")
        var table = state.head.data;
        var params = command.settings;

        params = (params) ? {
            direction: params.direction || "Rows",
            asc: params.asc || "A-Z",
            index: params.index || 0
        } : {
            direction: "Rows",
            asc: "A-Z",
            index: 0
        }


        if (!util.isNumber(params.index))
            throw new OrderImplError("Incompatible index value: " + JSON.stringify(params.index) + ".")


        if (params.direction != "Rows" && params.direction != "Columns")
            throw new OrderImplError("Incompatible direction value: " + JSON.stringify(params.direction) + ".")

        if (params.asc != "A-Z" && params.asc != "Z-A")
            throw new OrderImplError("Incompatible asc value: " + JSON.stringify(params.asc) + ".")

        try {
            state.head = {
                type: "table",
                data: impl(table, params)
            }
        } catch (e) {
            throw new OrderImplError(e.toString())
github Tubitv / envoy-node / src / envoy-context.ts View on Github external
export function assignHeader(
  header: HttpHeader,
  key: string,
  value: string | number | undefined | null
) {
  if (value === undefined || value === null) return;
  if (isNumber(value)) {
    if (isNaN(value)) {
      return;
    }
    header[key] = `${value}`;
  } else {
    header[key] = value;
  }
}
github nodekit-io / nodekit-darwin / src / nodekit / NKCore / lib-core / node / dgram.js View on Github external
Socket.prototype.setTTL = function(arg) {
  if (!util.isNumber(arg)) {
    throw new TypeError('Argument must be a number');
  }

  var err = this._handle.setTTL(arg);
  if (err) {
    throw errnoException(err, 'setTTL');
  }

  return arg;
};
github NativeScript / nativescript-dev-appium / lib / image-helper.ts View on Github external
public async clipRectangleImage(rect: IRectangle, path: string) {
        let imageToClip: PngJsImage;
        imageToClip = await this.readImage(path);
        let shouldExit = false;
        if (!isNumber(rect["x"])
            || !isNumber(rect["y"])
            || !isNumber(rect["width"])
            || !isNumber(rect["height"])) {
            shouldExit = true;
        }
        if (shouldExit) {
            logError(`Could not crop the image. Not enough data {x: ${rect["x"]}, y: ${rect["y"]}, width: ${rect["width"]}, height: ${rect["height"]}}`);
        }

        if (!shouldExit) {
            imageToClip.clip(rect.x, rect.y, rect.width, rect.height);
        } else {
            logWarn("Image will not be cropped!")
            return true;
        }
        return new Promise((resolve, reject) => {