🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

sort-unwind

Package Overview
Dependencies
Maintainers
0
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sort-unwind - npm Package Compare versions

Comparing version

to
3.0.0

dist/index.cjs

5

dist/index.d.ts

@@ -1,3 +0,4 @@

export declare const curried: (rank: number[]) => <T>(src: T[]) => [T[], number[]];
declare const curried: (rank: number[]) => <T>(src: T[]) => [T[], number[]];
declare const _default: <T>(rank: number[], src: T[]) => [T[], number[]];
export default _default;
export { curried, _default as default };

45

dist/index.js

@@ -1,25 +0,22 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.curried = void 0;
const curried = (rank) => (src) => {
if (src.length === 0)
return [[], []];
const zipped = [];
src.forEach((_, i) => {
zipped.push([rank[i], i, src[i]]);
});
// Array.sort will mutate the array, so we must make another
zipped.sort(([a], [b]) => a - b);
const dst = [];
const derank = [];
zipped.forEach(([_, i, o]) => {
derank.push(i);
dst.push(o);
});
return [dst, derank];
// src/index.ts
var curried = (rank) => (src) => {
if (src.length === 0) return [[], []];
const zipped = [];
src.forEach((_, i) => {
zipped.push([rank[i], i, src[i]]);
});
zipped.sort(([a], [b]) => a - b);
const dst = [];
const derank = [];
zipped.forEach(([_, i, o]) => {
derank.push(i);
dst.push(o);
});
return [dst, derank];
};
exports.curried = curried;
// if i understood generics better, i think this could go back
// to just being one exported function with an optional second
// param... but this is just simpler.
exports.default = (rank, src) => (0, exports.curried)(rank)(src);
var src_default = (rank, src) => curried(rank)(src);
export {
curried,
src_default as default
};
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vc3JjL2luZGV4LnRzIl0sCiAgInNvdXJjZXNDb250ZW50IjogWyJleHBvcnQgY29uc3QgY3VycmllZCA9XG4gIChyYW5rOiBudW1iZXJbXSkgPT5cbiAg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0FBQyxDQUFDLEdBQUcsQ0FBQyxDQUFDO0FBRXBDLFFBQU0sU0FBa0MsQ0FBQztBQUN6QyxNQUFJLFFBQVEsQ0FBQyxHQUFHLE1BQU07QUFDcEIsV0FBTyxLQUFLLENBQUMsS0FBSyxDQUFDLEdBQUcsR0FBRyxJQUFJLENBQUMsQ0FBQyxDQUFDO0FBQUEsRUFDbEMsQ0FBQztBQUVELFNBQU8sS0FBSyxDQUFDLENBQUMsQ0FBQyxHQUFHLENBQUMsQ0FBQyxNQUFNLElBQUksQ0FBQztBQUUvQixRQUFNLE1BQVcsQ0FBQztBQUNsQixRQUFNLFNBQW1CLENBQUM7QUFDMUIsU0FBTyxRQUFRLENBQUMsQ0FBQyxHQUFHLEdBQUcsQ0FBQyxNQUFNO0FBQzVCLFdBQU8sS0FBSyxDQUFDO0FBQ2IsUUFBSSxLQUFLLENBQUM7QUFBQSxFQUNaLENBQUM7QUFDRCxTQUFPLENBQUMsS0FBSyxNQUFNO0FBQ3JCO0FBS0YsSUFBTyxjQUFRLENBQUksTUFBZ0IsUUFBYSxRQUFRLElBQUksRUFBRSxHQUFHOyIsCiAgIm5hbWVzIjogW10KfQo=
{
"name": "sort-unwind",
"version": "2.1.2",
"version": "3.0.0",
"description": "Sorts an array and then unwinds that sort on another array",

@@ -8,7 +8,8 @@ "author": "Philihp Busby <philihp@gmail.com>",

"sideEffects": false,
"type": "module",
"main": "./dist/index.js",
"scripts": {
"build": "tsc -p tsconfig.build.json",
"lint": "eslint --ext .ts,.json,.js src",
"prepare": "husky install && npm run build",
"build": "tsup",
"lint": "eslint .",
"prepare": "husky && npm run build",
"test": "jest",

@@ -28,22 +29,20 @@ "test:coverage": "jest --coverage",

],
"dependencies": {},
"devDependencies": {
"@babel/cli": "7.21.0",
"@babel/core": "7.21.4",
"@babel/preset-env": "7.21.4",
"@philihp/eslint-config": "6.0.2",
"@philihp/prettier-config": "1.0.0",
"@types/jest": "29.5.0",
"@typescript-eslint/eslint-plugin": "5.59.0",
"@typescript-eslint/parser": "5.59.0",
"eslint": "8.38.0",
"eslint-import-resolver-typescript": "3.5.5",
"eslint-plugin-import": "2.27.5",
"fast-shuffle": "5.0.2",
"husky": "8.0.3",
"jest": "29.5.0",
"lint-staged": "13.2.1",
"prettier": "2.8.7",
"ts-jest": "29.1.0",
"typescript": "5.0.4"
"@tsconfig/recommended": "1.0.7",
"@types/jest": "29.5.12",
"esbuild-jest": "0.5.0",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-jest": "28.6.0",
"eslint-plugin-prettier": "5.1.3",
"fast-shuffle": "6.1.0",
"husky": "9.0.11",
"jest": "29.7.0",
"tsup": "8.1.0",
"typescript": "5.5.3",
"typescript-eslint": "7.15.0",
"lint-staged": "15.2.7",
"prettier": "3.3.2",
"ts-jest": "29.1.5"
},

@@ -58,69 +57,6 @@ "homepage": "https://github.com/philihp/sort-unwind#readme",

},
"jest": {
"preset": "ts-jest",
"testEnvironment": "node",
"modulePathIgnorePatterns": [
"dist/"
]
},
"lint-staged": {
"src/**/*.{js,json,ts}": [
"eslint --ext .js,.json,.ts --fix"
]
},
"prettier": "@philihp/prettier-config",
"eslintConfig": {
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"plugins": [
"@typescript-eslint"
],
"extends": [
"@philihp",
"plugin:jest/all",
"plugin:@typescript-eslint/recommended"
],
"settings": {
"import/extensions": [
".js",
".ts"
],
"import/parsers": {
"@typescript-eslint/parser": [
".ts"
]
},
"import/resolver": {
"typescript": {},
"node": {
"extensions": [
".js",
".ts"
]
}
}
},
"rules": {
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_"
}
],
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": [
"**/*.test.ts"
]
}
]
}
"engines": {
"node": ">=18.0.0"
}
}
[![Version](https://img.shields.io/npm/v/sort-unwind)](https://www.npmjs.com/package/sort-unwind)
[![Requirements Status](https://img.shields.io/librariesio/github/philihp/sort-unwind?color=green)](https://libraries.io/npm/sort-unwind)
![Tests](https://github.com/philihp/sort-unwind/workflows/tests/badge.svg)
[![Tests](https://github.com/philihp/sort-unwind/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/philihp/sort-unwind/actions/workflows/tests.yml)
[![Coverage Status](https://coveralls.io/repos/github/philihp/sort-unwind/badge.svg?branch=main)](https://coveralls.io/github/philihp/sort-unwind?branch=main)

@@ -5,0 +4,0 @@ ![Downloads](https://img.shields.io/npm/dt/sort-unwind)