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.4.2 to 0.5.0

42

dist/index.js

@@ -1,5 +0,2 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.unwrapArrayOfObjects = exports.objectToArray = exports.isAnyZero = exports.isAnyOne = exports.isAllZero = exports.isAllOne = exports.interpolateArray = exports.getNonZeroIndices = exports.fillAndMap = exports.addToArray = exports.accumulate = void 0;
const math_1 = require("@daeinc/math");
import { mix, roundF } from "@daeinc/math";
/**

@@ -14,3 +11,3 @@ * accumulate array values. ex. [50,50,50] => [50,100,150]

*/
const accumulate = (arr, precision = 4) => {
export const accumulate = (arr, precision = 4) => {
const result = [];

@@ -22,5 +19,4 @@ let sum = 0;

}
return result.map((val) => (0, math_1.roundF)(val, 4));
return result.map((val) => roundF(val, 4));
};
exports.accumulate = accumulate;
/**

@@ -36,3 +32,3 @@ * add to array in-place while limiting how many to keep history.

*/
const addToArray = (arr, entry, newArrayLen, mode = "first") => {
export const addToArray = (arr, entry, newArrayLen, mode = "first") => {
// add

@@ -52,3 +48,2 @@ if (mode === "first")

};
exports.addToArray = addToArray;
/**

@@ -60,3 +55,3 @@ * create a new array with given length and maps values

*/
const fillAndMap = (n, fn) => {
export const fillAndMap = (n, fn) => {
if (n > 0) {

@@ -67,3 +62,2 @@ return Array(n).fill(null).map(fn);

};
exports.fillAndMap = fillAndMap;
/**

@@ -74,3 +68,3 @@ * check for elements with non-zero value and return indices

*/
const getNonZeroIndices = (arr) => {
export const getNonZeroIndices = (arr) => {
const result = [];

@@ -83,3 +77,2 @@ for (let i = 0; i < arr.length; i++) {

};
exports.getNonZeroIndices = getNonZeroIndices;
/**

@@ -95,3 +88,3 @@ * interpolates between two 1d array of any size. for now, numbers only.

*/
const interpolateArray = (arrStart, arrTarget, t) => {
export const interpolateArray = (arrStart, arrTarget, t) => {
if (arrStart.length === 0 || arrTarget.length === 0)

@@ -104,6 +97,5 @@ throw new Error("interpolateArray(): arrays cannot be empty");

.map((_, i) => {
return (0, math_1.mix)(arrStart[i], arrTarget[i], t);
return mix(arrStart[i], arrTarget[i], t);
});
};
exports.interpolateArray = interpolateArray;
/**

@@ -114,4 +106,3 @@ * check if all values of array is one.

*/
const isAllOne = (arr) => arr.every((el) => el === 1);
exports.isAllOne = isAllOne;
export const isAllOne = (arr) => arr.every((el) => el === 1);
/**

@@ -122,4 +113,3 @@ * check if all values of array is zero.

*/
const isAllZero = (arr) => arr.every((el) => el === 0);
exports.isAllZero = isAllZero;
export const isAllZero = (arr) => arr.every((el) => el === 0);
/**

@@ -130,4 +120,3 @@ * check if any value of array is one

*/
const isAnyOne = (arr) => arr.some((el) => el === 1);
exports.isAnyOne = isAnyOne;
export const isAnyOne = (arr) => arr.some((el) => el === 1);
/**

@@ -138,4 +127,3 @@ * check if any value of array is zero

*/
const isAnyZero = (arr) => arr.some((el) => el === 0);
exports.isAnyZero = isAnyZero;
export const isAnyZero = (arr) => arr.some((el) => el === 0);
/**

@@ -147,6 +135,5 @@ * convert object key:value pairs into simple array of values

*/
const objectToArray = (obj, keys) => {
export const objectToArray = (obj, keys) => {
return keys.map((key) => obj[key]);
};
exports.objectToArray = objectToArray;
/**

@@ -160,3 +147,3 @@ * helper function to get object values inside an array. all objects must have same keys present.

*/
const unwrapArrayOfObjects = (arr, objKey) => {
export const unwrapArrayOfObjects = (arr, objKey) => {
return Array(arr.length)

@@ -173,3 +160,2 @@ .fill(null)

};
exports.unwrapArrayOfObjects = unwrapArrayOfObjects;
//# sourceMappingURL=index.js.map
{
"name": "@daeinc/array",
"version": "0.4.2",
"version": "0.5.0",
"description": "Array utilities",

@@ -19,7 +19,7 @@ "types": "./dist/index.d.ts",

"devDependencies": {
"jest": "^29.1.2",
"ts-jest": "^29.0.3"
"jest": "^29.3.1",
"ts-jest": "^29.0.5"
},
"dependencies": {
"@daeinc/math": "^0.4.0"
"@daeinc/math": "^0.5.0"
},

@@ -26,0 +26,0 @@ "publishConfig": {

Sorry, the diff of this file is not supported yet

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