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

sort-unwind

Package Overview
Dependencies
Maintainers
1
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
2.0.0

dist/index.d.ts

39

dist/index.js
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _ramda = require("ramda");
var _default = (0, _ramda.uncurryN)(2, function (rank) {
return (0, _ramda.pipe)((0, _ramda.addIndex)(_ramda.map)(function (element, idx) {
return [element, idx];
}), (0, _ramda.zip)(rank), (0, _ramda.sortBy)((0, _ramda.prop)(0)), (0, _ramda.map)((0, _ramda.prop)(1)), _ramda.transpose);
});
exports["default"] = _default;
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];
};
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);
{
"name": "sort-unwind",
"version": "1.0.0",
"version": "2.0.0",
"description": "Sorts an array and then unwinds that sort on another array",

@@ -10,5 +10,5 @@ "author": "Philihp Busby <philihp@gmail.com>",

"scripts": {
"build": "babel src -d dist",
"lint": "eslint src",
"prepare": "npm run build",
"build": "tsc -p tsconfig.build.json",
"lint": "eslint --ext .ts,.json,.js src",
"prepare": "husky install && npm run build",
"test": "jest",

@@ -28,14 +28,22 @@ "test:coverage": "jest --coverage",

],
"dependencies": {
"ramda": "0.27.1"
},
"dependencies": {},
"devDependencies": {
"@babel/cli": "7.13.0",
"@babel/core": "7.13.8",
"@babel/preset-env": "7.13.9",
"@philihp/eslint-config": "4.2.0",
"fast-shuffle": "4.3.0",
"husky": "5.1.3",
"lint-staged": "10.5.4",
"prettier": "2.2.1"
"@babel/cli": "7.18.9",
"@babel/core": "7.18.9",
"@babel/preset-env": "7.18.9",
"@philihp/eslint-config": "6.0.2",
"@philihp/prettier-config": "1.0.0",
"@types/jest": "28.1.6",
"@typescript-eslint/eslint-plugin": "5.36.1",
"@typescript-eslint/parser": "5.36.1",
"eslint": "8.23.0",
"eslint-import-resolver-typescript": "3.5.0",
"eslint-plugin-import": "2.26.0",
"fast-shuffle": "5.0.2",
"husky": "8.0.1",
"jest": "28.1.3",
"lint-staged": "13.0.3",
"prettier": "2.7.1",
"ts-jest": "28.0.7",
"typescript": "4.7.4"
},

@@ -51,2 +59,4 @@ "homepage": "https://github.com/philihp/sort-unwind#readme",

"jest": {
"preset": "ts-jest",
"testEnvironment": "node",
"modulePathIgnorePatterns": [

@@ -57,21 +67,61 @@ "dist/"

"lint-staged": {
"src/**/*.{js,jsx,json}": [
"eslint --fix"
"src/**/*.{js,json,ts}": [
"eslint --ext .js,.json,.ts --fix"
]
},
"prettier": {
"singleQuote": true,
"semi": false,
"trailingComma": "es5"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"prettier": "@philihp/prettier-config",
"eslintConfig": {
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"plugins": [
"@typescript-eslint"
],
"extends": [
"@philihp"
]
"@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"
]
}
]
}
}
}
[![Version](https://img.shields.io/npm/v/sort-unwind)](https://www.npmjs.com/package/sort-unwind)
[![Requirements Status](https://requires.io/github/philihp/fast-shuffle/requirements.svg?branch=main)](https://requires.io/github/philihp/fast-shuffle/requirements/?branch=main)
![Tests](https://github.com/philihp/sort-unwind/workflows/tests/badge.svg)

@@ -27,3 +28,3 @@ [![Coverage Status](https://coveralls.io/repos/github/philihp/sort-unwind/badge.svg?branch=main)](https://coveralls.io/github/philihp/sort-unwind?branch=main)

// sortedSuits <- ['♠', '♦', '♥', '♣']
// unwind <- [1, 3, 0, 2]
// tenet <- [1, 3, 0, 2]
```

@@ -43,1 +44,2 @@

- [@varenc](https://github.com/varenc) for showing me a clever way to do this.
- [@crosseye](https://github.com/crosseye) for working out a simpler way without a pipe