From 6e7620de0ac8c35bb36404f1d9182c50678a5900 Mon Sep 17 00:00:00 2001 From: Subhajit Sahu Date: Mon, 8 May 2023 01:37:20 +0530 Subject: [PATCH] :bug: chore: rearrange code --- package-lock.json | 4 +-- package.json | 2 +- src/index.ts | 68 +++++++++++++++++++++++------------------------ wiki | 2 +- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/package-lock.json b/package-lock.json index 709bccd75..1779557fb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "extra-array", - "version": "4.0.2", + "version": "4.0.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "extra-array", - "version": "4.0.2", + "version": "4.0.3", "license": "MIT", "devDependencies": { "@rollup/plugin-commonjs": "^24.1.0", diff --git a/package.json b/package.json index 0260fc9dc..51019955e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "extra-array", - "version": "4.0.2", + "version": "4.0.3", "description": "An array is a collection of values, stored contiguously.", "main": "index.js", "module": "index.mjs", diff --git a/src/index.ts b/src/index.ts index 9b79fb9ca..fe10957ce 100644 --- a/src/index.ts +++ b/src/index.ts @@ -130,28 +130,6 @@ function toSet(x: T[], fm: MapFunction | null=null): Set { // #region GENERATE // ---------------- -/** - * Convert an iterable to array. - * @param x an iterable - * @returns x as array - */ -export function fromIterable(x: Iterable): T[] { - return [...x]; -} -export {fromIterable as from}; - - -/** - * Convert an iterable to array! - * @param x an iterable (updatable if array!) - * @returns x as array - */ -export function fromIterable$(x: Iterable): T[] { - return Array.isArray(x)? x : [...x]; -} -export {fromIterable$ as from$}; - - /** * Generate array from given number range. * @param v start number @@ -197,6 +175,28 @@ export function fromApplication(fm: MapFunction, v: T, n: number): T[] return a; } export {fromApplication as fromApply}; + + +/** + * Convert an iterable to array. + * @param x an iterable + * @returns x as array + */ +export function fromIterable(x: Iterable): T[] { + return [...x]; +} +export {fromIterable as from}; + + +/** + * Convert an iterable to array! + * @param x an iterable (updatable if array!) + * @returns x as array + */ +export function fromIterable$(x: Iterable): T[] { + return Array.isArray(x)? x : [...x]; +} +export {fromIterable$ as from$}; // #endregion @@ -242,18 +242,6 @@ export function is(v: any): v is any[] { } -/** - * Examine if array is sorted. - * @param x an array - * @param fc compare function (a, b) - * @param fm map function (v, i, x) - * @returns x is sorted? - */ -export function isSorted(x: T[], fc: CompareFunction | null=null, fm: MapFunction | null=null): boolean { - return searchUnsortedValue(x, fc, fm) === -1; -} - - /** * Obtain all indices. * @param x an array @@ -3192,6 +3180,18 @@ export function cartesianProduct(xs: T[][], fm: MapFunction // #region SORT // ------------ +/** + * Examine if array is sorted. + * @param x an array + * @param fc compare function (a, b) + * @param fm map function (v, i, x) + * @returns x is sorted? + */ +export function isSorted(x: T[], fc: CompareFunction | null=null, fm: MapFunction | null=null): boolean { + return searchUnsortedValue(x, fc, fm) === -1; +} + + /** * Arrange values in order. * @param x an array diff --git a/wiki b/wiki index 4de4f82e8..b9477a9e8 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 4de4f82e8d0b747148fb76e0d6b69dde850812c1 +Subproject commit b9477a9e846b7808d718f9b0eddab1ce002b9299