MCPcopy Index your code
hub / github.com/tensorflow/tfjs-examples / assertPositiveInteger

Function assertPositiveInteger

snake-dqn/utils.js:50–59  ·  view source on GitHub ↗
(x, name)

Source from the content-addressed store, hash-verified

48
49
50export function assertPositiveInteger(x, name) {
51 if (!Number.isInteger(x)) {
52 throw new Error(
53 `Expected ${name} to be an integer, but received ${x}`);
54 }
55 if (!(x > 0)) {
56 throw new Error(
57 `Expected ${name} to be a positive number, but received ${x}`);
58 }
59}

Callers 2

constructorMethod · 0.90
constructorMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected