Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@daeinc/array

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@daeinc/array - npm Package Compare versions

Comparing version 0.3.3 to 0.3.4

2

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc