MCPcopy
hub / github.com/immutable-js/immutable-js / wrapIndex

Function wrapIndex

src/TrieUtils.ts:43–62  ·  view source on GitHub ↗
(
  iter: Collection<unknown, unknown>,
  index: number
)

Source from the content-addressed store, hash-verified

41}
42
43export function wrapIndex(
44 iter: Collection<unknown, unknown>,
45 index: number
46): number {
47 // This implements "is array index" which the ECMAString spec defines as:
48 //
49 // A String property name P is an array index if and only if
50 // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
51 // to 2^32−1.
52 //
53 // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects
54 if (typeof index !== 'number') {
55 const uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32
56 if ('' + uint32Index !== index || uint32Index === 4294967295) {
57 return NaN;
58 }
59 index = uint32Index;
60 }
61 return index < 0 ? ensureSize(iter) + index : index;
62}
63
64export function returnTrue(): true {
65 return true;

Callers 8

getMethod · 0.90
getMethod · 0.90
getMethod · 0.90
updateListFunction · 0.90
sliceFactoryFunction · 0.90
getFunction · 0.90
hasFunction · 0.90
getMethod · 0.90

Calls 1

ensureSizeFunction · 0.85

Tested by

no test coverage detected