New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@antoniovdlc/sort

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antoniovdlc/sort - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

134

dist/index.d.ts

@@ -1,55 +0,79 @@

import type { CompareFunction } from "./types";
import createCompareFunction from "./create-compare-fn";
/**
* Combine multipe sorting functions in order.
*
* Example:
* [
* { name: "Alice", age: 32 },
* { name: "Bob", age: 45 },
* { name: "Alice", age: 28 },
* ].sort(combine([
* alphabetically.by("name"),
* numerically.by("age").desc
* ]))
* =>
* [
* { name: "Alice", age: 32 },
* { name: "Alice", age: 28 },
* { name: "Bob", age: 45 },
* ]
*
* @param sortFns List of sorting functions
* @returns
*/
declare function combine(sortFns: Array<CompareFunction>): CompareFunction;
/**
* Sorts arrays alphabetically (taking into account case)
*
* Example: ["bob", "Alice", "tom", "Candice"].sort(alphabetically)
* => ["Alice", "Candice", "bob", "tom"]
*/
declare const alphabetically: import("./types").SortFunction;
/**
* Sorts arrays alphabetically (regardless of case)
*
* Example: ["bob", "Alice", "tom", "Candice"].sort(alphabeticallyBase)
* => ["Alice", "bob", "Candice", "tom"]
*/
declare const alphabeticallyBase: import("./types").SortFunction;
/**
* Sorts arrays chronologically
*
* Example: ["01-01-2001", "01-01-1970", "02-02-2002"].sort(chronologically)
* => ["01-01-1970", "01-01-2001", "02-02-2002"]
*/
declare const chronologically: import("./types").SortFunction;
/**
* Sorts arrays numerically
*
* Example: [1, 2, 23, 30, 4].sort(numerically)
* => [1, 2, 4, 23, 30]
*/
declare const numerically: import("./types").SortFunction;
export { combine, createCompareFunction };
export { alphabetically, alphabeticallyBase, chronologically, numerically };
declare module "types" {
export type Compare = string | number | Date | Record<string | number | symbol, any>;
export type CompareFunction = (a: Compare, b: Compare, direction?: number) => number;
type SortFunctionAscDesc = CompareFunction & {
asc: CompareFunction;
desc: CompareFunction;
};
export type SortFunction = SortFunctionAscDesc & {
by: (key: string) => SortFunctionAscDesc;
};
}
declare module "create-compare-fn" {
import type { CompareFunction, SortFunction } from "types";
/**
* Utility function to create custom compare function for sorting Arrays
* @param coerceType Function to coerce the types of values
* @param compareFn Compare function to apply to the values
* @returns Custom compare function
*/
function createCompareFunction(coerceType?: Function, compareFn?: CompareFunction): SortFunction;
export default createCompareFunction;
}
declare module "index" {
import type { CompareFunction } from "types";
import createCompareFunction from "create-compare-fn";
/**
* Combine multipe sorting functions in order.
*
* Example:
* [
* { name: "Alice", age: 32 },
* { name: "Bob", age: 45 },
* { name: "Alice", age: 28 },
* ].sort(combine([
* alphabetically.by("name"),
* numerically.by("age").desc
* ]))
* =>
* [
* { name: "Alice", age: 32 },
* { name: "Alice", age: 28 },
* { name: "Bob", age: 45 },
* ]
*
* @param sortFns List of sorting functions
* @returns
*/
function combine(sortFns: Array<CompareFunction>): CompareFunction;
/**
* Sorts arrays alphabetically (taking into account case)
*
* Example: ["bob", "Alice", "tom", "Candice"].sort(alphabetically)
* => ["Alice", "Candice", "bob", "tom"]
*/
const alphabetically: import("types").SortFunction;
/**
* Sorts arrays alphabetically (regardless of case)
*
* Example: ["bob", "Alice", "tom", "Candice"].sort(alphabeticallyBase)
* => ["Alice", "bob", "Candice", "tom"]
*/
const alphabeticallyBase: import("types").SortFunction;
/**
* Sorts arrays chronologically
*
* Example: ["01-01-2001", "01-01-1970", "02-02-2002"].sort(chronologically)
* => ["01-01-1970", "01-01-2001", "02-02-2002"]
*/
const chronologically: import("types").SortFunction;
/**
* Sorts arrays numerically
*
* Example: [1, 2, 23, 30, 4].sort(numerically)
* => [1, 2, 4, 23, 30]
*/
const numerically: import("types").SortFunction;
export { combine, createCompareFunction };
export { alphabetically, alphabeticallyBase, chronologically, numerically };
}
{
"name": "@antoniovdlc/sort",
"version": "1.2.1",
"version": "1.2.2",
"description": "Custom compare functions for sorting arrays.",

@@ -22,3 +22,3 @@ "main": "dist/index.cjs.js",

"build": "npm run build:types && npm run build:lib",
"build:types": "tsc src/*.ts --declaration --emitDeclarationOnly --outDir dist",
"build:types": "tsc src/*.ts --declaration --emitDeclarationOnly --outFile dist/index.d.ts",
"build:lib": "rollup -c",

@@ -48,3 +48,2 @@ "postversion": "git push && git push --tags"

"eslint-config-prettier": "^8.3.0",
"eslint-plugin-jest": "^25.0.5",
"husky": "^7.0.2",

@@ -51,0 +50,0 @@ "lint-staged": "^12.0.2",

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