@daeinc/array
Advanced tools
Comparing version 0.3.3 to 0.3.4
{ | ||
"name": "@daeinc/array", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"description": "Array utilities", | ||
@@ -5,0 +5,0 @@ "types": "./dist/index.d.ts", |
@@ -21,3 +21,6 @@ # @daeinc/array | ||
const accumulate: (arr: number[], precision?: number) => number[]; | ||
``` | ||
Takes in a number array and returns a new array with values accumulated. For example, the input array `[1, 2, 3, 4]` will return `[1, 3, 6, 10]`. It also takes an optional parameter `precision`(default=4) to compensate for float rounding error. The original values are used while summing, but the return values will be rounded. | ||
```ts | ||
const addToArray: <T>( | ||
@@ -29,7 +32,16 @@ arr: T[], | ||
) => T[]; | ||
``` | ||
Adds a new element to array in-place while limiting how many to keep history. The mode `first` will insert at the beginning of the array. | ||
```ts | ||
const fillAndMap: <T>(n: number, fn: (el: null, idx: number) => T) => T[]; | ||
``` | ||
Creates a new array with given length and maps values | ||
```ts | ||
const getNonZeroIndices: (arr: number[]) => number[]; | ||
``` | ||
Check for elements with non-zero values and return indices. | ||
```ts | ||
const interpolateArray: ( | ||
@@ -40,11 +52,26 @@ arrStart: number[], | ||
) => number[]; | ||
``` | ||
Interpolates between two 1-dimensional arrays of same size. | ||
```ts | ||
const isAllOne: (arr: number[]) => boolean; | ||
``` | ||
Returns `true` if all elements of input array is `1`. | ||
```ts | ||
const isAllZero: (arr: number[]) => boolean; | ||
``` | ||
Returns `true` if all elements of input array is `0`. | ||
```ts | ||
const isAnyOne: (arr: number[]) => boolean; | ||
``` | ||
Returns `true` if any element of input array is `1`. | ||
```ts | ||
const isAnyZero: (arr: number[]) => boolean; | ||
``` | ||
Returns `true` if any element of input array is `0`. | ||
```ts | ||
const unwrapArrayOfObjects: ( | ||
@@ -56,4 +83,4 @@ arr: { | ||
) => any[]; | ||
//# sourceMappingURL=index.d.ts.map | ||
``` | ||
A helper function to get object values inside an array. All objects must have same keys present. For example, when the input array is `[ {name: val1}, {name: val2} ]`, calling `unwrapArrayOfObjects(arr, "name")` will return `[val1, val2]`. | ||
@@ -60,0 +87,0 @@ ## To dos |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15540
90