How to use the random-int function in random-int

To help you get started, we’ve selected a few random-int 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 pubkey / rxdb / test / helper / schema-objects.ts View on Github external
export function compoundIndexNoString(): CompoundIndexNoStringDocumentType {
    return {
        passportId: randomToken(12),
        passportCountry: { [randomToken(12)]: randomToken(12) },
        age: randomInt(10, 50)
    };
}
github pubkey / rxdb / test / helper / schema-objects.ts View on Github external
export function human(
    passportId: string = randomToken(12)
): HumanDocumentType {
    return {
        passportId: passportId,
        firstName: faker.name.firstName(),
        lastName: faker.name.lastName(),
        age: randomInt(10, 50)
    };
}
github pubkey / rxdb / test / helper / schema-objects.ts View on Github external
export function bigHumanDocumentType(): BigHumanDocumentType {
    return {
        passportId: randomToken(12),
        dnaHash: randomToken(12),
        firstName: faker.name.firstName(),
        lastName: faker.name.lastName(),
        age: randomInt(10, 50)
    };
}
github pubkey / rxdb / test / helper / schema-objects.ts View on Github external
export function compoundIndex(): CompoundIndexDocumentType {
    return {
        passportId: randomToken(12),
        passportCountry: randomToken(12),
        age: randomInt(10, 50)
    };
}
github pubkey / rxdb / test / helper / schema-objects.ts View on Github external
export function simpleHumanV3(): SimpleHumanV3DocumentType {
    return {
        passportId: randomToken(12),
        age: randomInt(10, 50)
    };
}
github react-paper / react-paper-bindings / demo / src / Paper / hoc / withRectangleTool.js View on Github external
mouseDown = (e) => {
      this.props.deselectItem()
      const paper = e.tool._scope
      const rectangle = new paper.Path.Rectangle({
        center: e.point,
        fillColor: randomColor(),
        size: randomInt(20,120),
      })
      const item = this.props.addItem(rectangle.layer, {
        type: 'Rectangle',
        pathData: rectangle.getPathData(),
        fillColor: rectangle.fillColor.toCSS(true),
      })
      console.log(rectangle)
      console.log(rectangle.getPathData())
      rectangle.remove()
      this.props.selectItem(item)
    }
github Zhouzi / TheaterJS / src / keyboard.js View on Github external
for (const c in keyboard) {
      if (!keyboard.hasOwnProperty(c) || c === ch) continue;

      p = keyboard[c];

      if (
        Math.abs(charPosition.x - p.x) <= threshold &&
        Math.abs(charPosition.y - p.y) <= threshold
      ) {
        nearbyChars.push(c);
      }
    }

    let randomChar =
      nearbyChars.length > 0
        ? nearbyChars[randomInt(0, nearbyChars.length - 1)]
        : this.randomChar(locale);

    if (uppercase) {
      randomChar = randomChar.toUpperCase();
    }

    return randomChar;
  },
github react-paper / react-paper-bindings / demo / src / Paper / Paper.js View on Github external
constructor(props) {
    super(props)
    this.state = {
      imageLoaded: false,
      loaded: false,
      showLayers: true,
      size: [randomInt(40,320),randomInt(40,320)],
      open: false,
    }
    this._view = null
  }
github mattdesl / codevember / src / 20.js View on Github external
function draw () {
    const blockCount = randomInt(10, 40)
    const blockSize = width / blockCount
    const cols = width / blockSize
    const count = blockCount * (height + blockCount * 2)
    const rows = Math.ceil(count / cols)
    const half = blockSize / 2
    ctx.beginPath()
    ctx.translate(half, half)
    for (let i = 0; i < (rows * cols); i++) {
      const x = Math.floor(i % cols) * blockSize
      const y = Math.floor(i / cols) * blockSize
      let s = random(0.01, 0.05)
      let n = simplex.noise3D(x * s, y * s, Date.now() / 1000)
      if (x === 0) ctx.moveTo(x, y)
      else ctx.lineTo(x, y)
      ctx.lineTo(x, y + blockSize / 2 * n)
    }
github Zhouzi / TheaterJS / src / keyboard.js View on Github external
randomChar(locale) {
    if (!this.supports(locale)) {
      throw new Error(`locale "${locale}" is not supported`);
    }

    const chars = keyboards[locale].list.join("");
    return chars.charAt(randomInt(0, chars.length - 1));
  }
};

random-int

Generate a random integer

MIT
Latest version published 4 years ago

Package Health Score

53 / 100
Full package analysis

Popular random-int functions