How to use is-number - 5 common examples

To help you get started, we’ve selected a few is-number 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 iamvictorli / Daily-Coding-Problem / solutions / 21-30 / Problem29.js View on Github external
function stringDecoding(string) {
  if (string.length === 0) return '';
  let currCount = 0;
  let i = 0;
  let decoding = '';

  while (i < string.length) {
    const char = string.charAt(i);
    if (isNumber(char)) {
      const num = Number(char);
      currCount = currCount * 10 + num;
    } else {
      decoding = addCountAmount(decoding, char, currCount);
      currCount = 0;
    }

    i++;
  }

  return decoding;
}
github staeco / iris-ql / src / types / index.js View on Github external
  check: (v) => isNumber(v),
  hydrate: (txt) => types.cast(txt, 'numeric')
github enchantinggg4 / vibejs / src / entity / EntitySubject.js View on Github external
_processReference(value, stateProvider) {
        if (isNumber(value)) {
            return value;
        } else if (value == null) {
            return value;
        } else if ('id' in value && isNumber(value.id)) {
            return value.id
        } else {
            throw new Error("Invalid reference: expected id, null or subject")
        }
    }
github chanzuckerberg / cellxgene / client / src / components / categorical / util.js View on Github external
values.forEach(v => {
    if (isUserAnno && v[0] === globals.unassignedCategoryLabel) {
      unassigned.push(v);
    } else if (isNumber(v[0])) {
      ints.push(v);
    } else {
      strings.push(v);
    }
  });
github enchantinggg4 / vibejs / src / entity / EntitySubject.js View on Github external
_processReference(value, stateProvider) {
        if (isNumber(value)) {
            return value;
        } else if (value == null) {
            return value;
        } else if ('id' in value && isNumber(value.id)) {
            return value.id
        } else {
            throw new Error("Invalid reference: expected id, null or subject")
        }
    }

is-number

Returns true if a number or string value is a finite number. Useful for regex matches, parsing, user input, etc.

MIT
Latest version published 6 years ago

Package Health Score

71 / 100
Full package analysis

Popular is-number functions