fake-indexeddb
Version:
Fake IndexedDB: a pure JS in-memory implementation of the IndexedDB API
13 lines (12 loc) • 335 B
JavaScript
// https://heycam.github.io/webidl/#EnforceRange
const enforceRange = (num, type) => {
const min = 0;
const max = type === "unsigned long" ? 4294967295 : 9007199254740991;
if (isNaN(num) || num < min || num > max) {
throw new TypeError();
}
if (num >= 0) {
return Math.floor(num);
}
};
export default enforceRange;