UNPKG

glitter-sdk-js

Version:

A light client which talks to your Glitter over Http

15 lines (12 loc) 380 B
'use strict' function safeParseInt (nStr) { let n = parseInt(nStr) if (!Number.isSafeInteger(n)) { throw Error(`Value ${JSON.stringify(nStr)} is not an integer in the valid range`) } if (String(n) !== String(nStr)) { throw Error(`Value ${JSON.stringify(nStr)} is not a canonical integer string representation`) } return n } module.exports = { safeParseInt }