Summary
This package contains the collection of useful calculating fields for arrays.
API
- Add
- GetByIndices
- GetLength
- Has
- Merge
- Remove
- RemoveMultiple
- SearchForIndices
- Toggle
- UpdateWithPattern
API methods clarification
Add
Signature
/* arguments object */ payload: */* returns */
Usage example
const Add = ; const testArray = 123; // [1, 2, 3, 4, 5]const a = testArray; // [1, 2, 3, 4]const b = testArray;
GetByIndices
Signature
/* arguments object */ indices: number ignoreIndicesOutOfArray: boolean/* returns */
Usage example
const GetByIndices = ; const testArray = 7 8 9; // [7, 9]const a = testArray; // [7, 9, undefined]const b = testArray; // [9, 7]const c = testArray; // [9, 9, 9, 9]const d = testArray;
GetLength
Signature
/* arguments object */ errorValue?: number skipUndefinedValues?: boolean skipNullValues?: boolean/* returns */ number
Usage example
const GetLength = ; const testArray = 7 undefined null null;const notAnArray = 55; // 4const a = testArray;// 3const b = testArray;// 2const c = testArray;// 1const d = testArray;// -1const e = notAnArray;// -10const f = notAnArray;
Has
Signature
/* arguments object */ element: * boolean/* returns */ boolean
Usage example
const Has = ;const Primitives = const comparePrimitives = ; const testArray = 123; // trueconst a = testArray; // falseconst b = testArray;
Merge
Signature
/* arguments object */ payload: * boolean shouldReplaceRecordsWithNewOnes?: boolean/* returns */ boolean
Usage example
const Merge = ;const Primitives = const comparePrimitives = ; const testArray = 1 2 3 4; // [1, 2, 3, 4, 5]const a = testArray; // [1, 2, 3, 4]const b = testArray; // [1, 2, 3, 4, 5]const c = testArray;
Remove
Signature
/* arguments object */ element: * boolean/* returns */ *
Usage example
const Remove = ;const Primitives = const comparePrimitives = ; const testArrayOfDigits = 1 2 3;const testArrayOfObjects = id: 1 id: 2 id: 3; // [1, 3]const a = testArrayOfDigits; // [{id: 2}, {id: 3}]const b = testArrayOfObjects;
RemoveMultiple
Signature
/* arguments object */ elements: * boolean/* returns */ *
Usage example
const RemoveMultiple = ;const Primitives = const comparePrimitives = ; const testArrayOfDigits = 1 2 3;const testArrayOfObjects = id: 1 id: 2 id: 3; //[2]const a = testArrayOfDigits; //[{id: 3}]const b = testArrayOfObjects;
SearchForIndices
Signature
/* arguments object */ boolean/* returns */ number
Usage example
const SearchForIndices = ; const testArrayOfDigits = 1 2 3 4 5 6; //[0, 2, 4, 5]const indices = testArrayOfDigits;
Toggle
Signature
/* arguments object */ element: * boolean/* returns */ *
Usage example
const Toggle = ;const Primitives = const comparePrimitives = ; const testArrayOfDigits = 1 2 3; const toggle1 = ; // [2, 3]const arrayWithToggled1 = ; // [2, 3, 1]const arrayWithToggled1Twice = ;
UpdateWithPattern
Signature
/* arguments object */ // keys of updating pattern are required indices, // values are according calculating fields updatingPattern: object/* returns */ *
Usage example
const UpdateWithPattern = ;const Create = ; const testStore = ; testStore; // [16, 4, -97]const fullArray = testStore