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

swiss-ak

Package Overview
Dependencies
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swiss-ak - npm Package Compare versions

Comparing version 2.5.2 to 2.6.0

32

dist/index.js

@@ -203,7 +203,2 @@ var __defProp = Object.defineProperty;

((ArrayTools2) => {
let utils;
((utils2) => {
utils2.isNumString = (text) => Boolean(text.match(/^[0-9-.]+$/));
utils2.partitionNums = (ignoreCase) => (name) => (ignoreCase ? name.toLowerCase() : name).split(/([0-9]+)/).map((s) => utils2.isNumString(s) ? Number(s) : s);
})(utils = ArrayTools2.utils || (ArrayTools2.utils = {}));
ArrayTools2.create = (length = 1, value = 1) => new Array(Math.floor(Math.max(0, length))).fill(value);

@@ -261,2 +256,27 @@ ArrayTools2.filled = ArrayTools2.create;

};
ArrayTools2.findAndRemove = (array, predicate, ...insertItems) => {
const index = array.findIndex(predicate);
if (index === -1)
return void 0;
return array.splice(index, 1, ...insertItems)[0];
};
ArrayTools2.findLastAndRemove = (array, predicate, ...insertItems) => {
const reverseIndex = ArrayTools2.reverse(array).findIndex(predicate);
const index = reverseIndex === -1 ? -1 : array.length - 1 - reverseIndex;
if (index === -1)
return void 0;
return array.splice(index, 1, ...insertItems)[0];
};
ArrayTools2.filterAndRemove = (array, predicate) => {
const result = array.filter(predicate);
result.forEach((item) => {
ArrayTools2.findAndRemove(array, (i) => i === item);
});
return result;
};
let utils;
((utils2) => {
utils2.isNumString = (text) => Boolean(text.match(/^[0-9-.]+$/));
utils2.partitionNums = (ignoreCase) => (name) => (ignoreCase ? name.toLowerCase() : name).split(/([0-9]+)/).map((s) => utils2.isNumString(s) ? Number(s) : s);
})(utils = ArrayTools2.utils || (ArrayTools2.utils = {}));
})(ArrayTools || (ArrayTools = {}));

@@ -790,2 +810,3 @@ var create = ArrayTools.create;

StringTools2.repeat = (maxLength, repeated) => (repeated && typeof repeated === "string" ? repeated : "").repeat(Math.max(0, maxLength));
StringTools2.clx = (...args) => processClxArray(args).join(" ");
const caseHandler = (overrideSplitter) => {

@@ -870,3 +891,2 @@ const getSplit = (input = "") => {

}).flat();
StringTools2.clx = (...args) => processClxArray(args).join(" ");
let matchBrackets;

@@ -873,0 +893,0 @@ ((matchBrackets2) => {

4

package.json
{
"name": "swiss-ak",
"version": "2.5.2",
"version": "2.6.0",
"author": "Jack Cannon <jackc@annon.co.uk> (http://c.annon.co.uk/)",

@@ -23,3 +23,3 @@ "license": "MIT",

"jest": "^28.1.3",
"swiss-docs": "^0.6.2",
"swiss-docs": "^0.7.2",
"ts-jest": "^28.0.7",

@@ -26,0 +26,0 @@ "tsup": "^6.2.1",

@@ -8,4 +8,2 @@ import { fn } from './fn';

*
* - `ArrayTools`
*
* A collection of useful array functions.

@@ -16,37 +14,3 @@ */

/**<!-- DOCS: ArrayTools.utils 101 ### -->
* utils
*
* - `ArrayTools.utils`
*
* Small helper functions that may help, but aren't important enough to be in ArrayTools directly
*/
export namespace utils {
// SWISS-DOCS-JSDOC-REMOVE-PREV-LINE
/**<!-- DOCS: ArrayTools.utils.isNumString 101 #### -->
* isNumString
*
* - `ArrayTools.utils.isNumString`
*
* Returns true if the given string is a number
* @param {string} text
* @returns {boolean}
*/
export const isNumString = (text: string) => Boolean(text.match(/^[0-9-.]+$/));
/**<!-- DOCS: ArrayTools.utils.partitionNums 101 #### -->
* partitionNums
*
* - `ArrayTools.utils.partitionNums`
*
* Splits a string into an array of strings and numbers
* @param {boolean} ignoreCase
* @returns {(name: string) => (string | number)[]}
*/
export const partitionNums = (ignoreCase: boolean) => (name: string) =>
(ignoreCase ? name.toLowerCase() : name).split(/([0-9]+)/).map((s) => (isNumString(s) ? Number(s) : s));
} // SWISS-DOCS-JSDOC-REMOVE-THIS-LINE
/**<!-- DOCS: ArrayTools.create ### -->
/**<!-- DOCS: ArrayTools.create ### @ -->
* create

@@ -70,3 +34,3 @@ *

/**<!-- DOCS: ArrayTools.range ### -->
/**<!-- DOCS: ArrayTools.range ### @ -->
* range

@@ -103,3 +67,3 @@ *

/**<!-- DOCS: ArrayTools.zip ### -->
/**<!-- DOCS: ArrayTools.zip ### @ -->
* zip

@@ -125,3 +89,3 @@ *

/**<!-- DOCS: ArrayTools.zipMax ### -->
/**<!-- DOCS: ArrayTools.zipMax ### @ -->
* zipMax

@@ -147,3 +111,3 @@ *

/**<!-- DOCS: ArrayTools.sortByMapped ### -->
/**<!-- DOCS: ArrayTools.sortByMapped ### @ -->
* sortByMapped

@@ -178,3 +142,3 @@ *

/**<!-- DOCS: ArrayTools.randomise ### -->
/**<!-- DOCS: ArrayTools.randomise ### @ -->
* randomise

@@ -199,3 +163,3 @@ *

/**<!-- DOCS: ArrayTools.reverse ### -->
/**<!-- DOCS: ArrayTools.reverse ### @ -->
* reverse

@@ -224,3 +188,3 @@ *

/**<!-- DOCS: ArrayTools.entries ### -->
/**<!-- DOCS: ArrayTools.entries ### @ -->
* entries

@@ -247,3 +211,3 @@ *

/**<!-- DOCS: ArrayTools.repeat ### -->
/**<!-- DOCS: ArrayTools.repeat ### @ -->
* repeat

@@ -269,3 +233,3 @@ *

/**<!-- DOCS: ArrayTools.roll ### -->
/**<!-- DOCS: ArrayTools.roll ### @ -->
* roll

@@ -291,3 +255,3 @@ *

/**<!-- DOCS: ArrayTools.sortNumberedText ### -->
/**<!-- DOCS: ArrayTools.sortNumberedText ### @ -->
* sortNumberedText

@@ -319,3 +283,3 @@ *

/**<!-- DOCS: ArrayTools.partition ### -->
/**<!-- DOCS: ArrayTools.partition ### @ -->
* partition

@@ -344,3 +308,3 @@ *

/**<!-- DOCS: ArrayTools.groupObj ### -->
/**<!-- DOCS: ArrayTools.groupObj ### @ -->
* groupObj

@@ -386,3 +350,3 @@ *

/**<!-- DOCS: ArrayTools.group ### -->
/**<!-- DOCS: ArrayTools.group ### @ -->
* group

@@ -414,2 +378,103 @@ *

};
/**<!-- DOCS: ArrayTools.findAndRemove ### @ -->
* findAndRemove
*
* - `ArrayTools.findAndRemove`
*
* Find the first item in an array that matches a given predicate, and remove it from the array
*
* > **Note:** This function mutates the provided array
* @param {T[]} array the array to mutate
* @param {(item: T, index: number, arr: T[]) => any} predicate a function that returns true/truthy if the item should be removed
* @param {...T} [insertItems] items to insert in place of the removed item
* @returns {T} the removed item (undefined if not found)
*/
export const findAndRemove = <T extends unknown>(
array: T[],
predicate: (item: T, index: number, arr: T[]) => any,
...insertItems: T[]
): T | undefined => {
const index = array.findIndex(predicate);
if (index === -1) return undefined;
return array.splice(index, 1, ...insertItems)[0];
};
/**<!-- DOCS: ArrayTools.findLastAndRemove ### @ -->
* findLastAndRemove
*
* - `ArrayTools.findLastAndRemove`
*
* Find the last item in an array that matches a given predicate, and remove it from the array
*
* > **Note:** This function mutates the provided array
* @param {T[]} array the array to mutate
* @param {(item: T, index: number, arr: T[]) => any} predicate a function that returns true/truthy if the item should be removed
* @param {...T} [insertItems] items to insert in place of the removed item
* @returns {T} the removed item (undefined if not found)
*/
export const findLastAndRemove = <T extends unknown>(
array: T[],
predicate: (item: T, index: number, arr: T[]) => any,
...insertItems: T[]
): T | undefined => {
const reverseIndex = ArrayTools.reverse(array).findIndex(predicate);
const index = reverseIndex === -1 ? -1 : array.length - 1 - reverseIndex;
if (index === -1) return undefined;
return array.splice(index, 1, ...insertItems)[0];
};
/**<!-- DOCS: ArrayTools.filterAndRemove ### @ -->
* filterAndRemove
*
* - `ArrayTools.filterAndRemove`
*
* Find the items in an array that matches a given predicate, and remove them from the array
*
* > **Note:** This function mutates the provided array
* @param {T[]} array the array to mutate
* @param {(item: T, index: number, arr: T[]) => any} predicate a function that returns true/truthy if the item should be removed
* @returns {T[]} the removed items
*/
export const filterAndRemove = <T extends unknown>(array: T[], predicate: (item: T, index: number, arr: T[]) => any): T[] => {
const result = array.filter(predicate);
result.forEach((item) => {
findAndRemove(array, (i) => i === item);
});
return result;
};
/**<!-- DOCS: ArrayTools.utils ### @ -->
* utils
*
* - `ArrayTools.utils`
*
* Small helper functions that may help, but aren't important enough to be in ArrayTools directly
*/
export namespace utils {
// SWISS-DOCS-JSDOC-REMOVE-PREV-LINE
/**<!-- DOCS: ArrayTools.utils.isNumString #### @ -->
* isNumString
*
* - `ArrayTools.utils.isNumString`
*
* Returns true if the given string is a number
* @param {string} text
* @returns {boolean}
*/
export const isNumString = (text: string) => Boolean(text.match(/^[0-9-.]+$/));
/**<!-- DOCS: ArrayTools.utils.partitionNums #### @ -->
* partitionNums
*
* - `ArrayTools.utils.partitionNums`
*
* Splits a string into an array of strings and numbers
* @param {boolean} ignoreCase
* @returns {(name: string) => (string | number)[]}
*/
export const partitionNums = (ignoreCase: boolean) => (name: string) =>
(ignoreCase ? name.toLowerCase() : name).split(/([0-9]+)/).map((s) => (isNumString(s) ? Number(s) : s));
} // SWISS-DOCS-JSDOC-REMOVE-THIS-LINE
} // SWISS-DOCS-JSDOC-REMOVE-THIS-LINE

@@ -416,0 +481,0 @@

@@ -562,3 +562,3 @@ import { MathsTools } from './MathsTools';

/**<!-- DOCS: ColourTools.parse ### -->
/**<!-- DOCS: ColourTools.parse ### @ -->
* parse

@@ -611,3 +611,3 @@ *

/**<!-- DOCS: ColourTools.toHex ### -->
/**<!-- DOCS: ColourTools.toHex ### @ -->
* toHex

@@ -630,3 +630,3 @@ *

/**<!-- DOCS: ColourTools.getLuminance ### -->
/**<!-- DOCS: ColourTools.getLuminance ### @ -->
* getLuminance

@@ -658,3 +658,3 @@ *

/**<!-- DOCS: ColourTools.toYUV ### -->
/**<!-- DOCS: ColourTools.toYUV ### @ -->
* toYUV

@@ -682,3 +682,3 @@ *

/**<!-- DOCS: ColourTools.toHSL ### -->
/**<!-- DOCS: ColourTools.toHSL ### @ -->
* toHSL

@@ -736,3 +736,3 @@ *

/**<!-- DOCS: ColourTools.fromHSL ### -->
/**<!-- DOCS: ColourTools.fromHSL ### @ -->
* fromHSL

@@ -771,3 +771,3 @@ *

/**<!-- DOCS: ColourTools.invertColour ### -->
/**<!-- DOCS: ColourTools.invertColour ### @ -->
* invertColour

@@ -795,3 +795,3 @@ *

/**<!-- DOCS: ColourTools.getContrastedColour ### -->
/**<!-- DOCS: ColourTools.getContrastedColour ### @ -->
* getContrastedColour

@@ -814,3 +814,3 @@ *

/**<!-- DOCS: ColourTools.getLimitedColour ### -->
/**<!-- DOCS: ColourTools.getLimitedColour ### @ -->
* getLimitedColour

@@ -817,0 +817,0 @@ *

@@ -16,3 +16,3 @@ // import { ms, wait, fn }

/**<!-- DOCS: ErrorTools.tryOr ### -->
/**<!-- DOCS: ErrorTools.tryOr ### @ -->
* tryOr

@@ -41,3 +41,3 @@ *

/**<!-- DOCS: ErrorTools.retry ### -->
/**<!-- DOCS: ErrorTools.retry ### @ -->
* retry

@@ -81,3 +81,3 @@ *

/**<!-- DOCS: ErrorTools.retryOr ### -->
/**<!-- DOCS: ErrorTools.retryOr ### @ -->
* retryOr

@@ -84,0 +84,0 @@ *

@@ -12,3 +12,3 @@ import { MathsTools } from './MathsTools';

/**<!-- DOCS: fn.noop ### -->
/**<!-- DOCS: fn.noop ### @ -->
* noop

@@ -28,3 +28,3 @@ *

/**<!-- DOCS: fn.noact ### -->
/**<!-- DOCS: fn.noact ### @ -->
* noact

@@ -45,3 +45,3 @@ *

/**<!-- DOCS: fn.result ### -->
/**<!-- DOCS: fn.result ### @ -->
* result

@@ -65,3 +65,3 @@ *

/**<!-- DOCS: fn.resolve ### -->
/**<!-- DOCS: fn.resolve ### @ -->
* resolve

@@ -82,3 +82,3 @@ *

/**<!-- DOCS: fn.reject ### -->
/**<!-- DOCS: fn.reject ### @ -->
* reject

@@ -104,3 +104,3 @@ *

*/
/**<!-- DOCS: fn.exists #### -->
/**<!-- DOCS: fn.exists #### @ -->
* exists

@@ -122,3 +122,3 @@ *

/**<!-- DOCS: fn.isTruthy #### -->
/**<!-- DOCS: fn.isTruthy #### @ -->
* isTruthy

@@ -141,3 +141,3 @@ *

/**<!-- DOCS: fn.isFalsy #### -->
/**<!-- DOCS: fn.isFalsy #### @ -->
* isFalsy

@@ -160,3 +160,3 @@ *

/**<!-- DOCS: fn.isEmpty #### -->
/**<!-- DOCS: fn.isEmpty #### @ -->
* isEmpty

@@ -179,3 +179,3 @@ *

/**<!-- DOCS: fn.isNotEmpty #### -->
/**<!-- DOCS: fn.isNotEmpty #### @ -->
* isNotEmpty

@@ -198,3 +198,3 @@ *

/**<!-- DOCS: fn.isEqual #### -->
/**<!-- DOCS: fn.isEqual #### @ -->
* isEqual

@@ -219,3 +219,3 @@ *

/**<!-- DOCS: fn.isNotEqual #### -->
/**<!-- DOCS: fn.isNotEqual #### @ -->
* isNotEqual

@@ -240,3 +240,3 @@ *

/**<!-- DOCS: fn.dedupe #### -->
/**<!-- DOCS: fn.dedupe #### @ -->
* dedupe

@@ -260,3 +260,3 @@ *

/**<!-- DOCS: fn.dedupeMapped #### -->
/**<!-- DOCS: fn.dedupeMapped #### @ -->
* dedupeMapped

@@ -291,3 +291,3 @@ *

*/
/**<!-- DOCS: fn.toString #### -->
/**<!-- DOCS: fn.toString #### @ -->
* toString

@@ -309,3 +309,3 @@ *

/**<!-- DOCS: fn.toNumber #### -->
/**<!-- DOCS: fn.toNumber #### @ -->
* toNumber

@@ -327,3 +327,3 @@ *

/**<!-- DOCS: fn.toBool #### -->
/**<!-- DOCS: fn.toBool #### @ -->
* toBool

@@ -346,3 +346,3 @@ *

/**<!-- DOCS: fn.toProp #### -->
/**<!-- DOCS: fn.toProp #### @ -->
* toProp

@@ -367,3 +367,3 @@ *

/**<!-- DOCS: fn.toFixed #### -->
/**<!-- DOCS: fn.toFixed #### @ -->
* toFixed

@@ -395,3 +395,3 @@ *

*/
/**<!-- DOCS: fn.asc #### -->
/**<!-- DOCS: fn.asc #### @ -->
* asc

@@ -418,3 +418,3 @@ *

/**<!-- DOCS: fn.desc #### -->
/**<!-- DOCS: fn.desc #### @ -->
* desc

@@ -443,3 +443,3 @@ *

/**<!-- DOCS: fn.byProp #### -->
/**<!-- DOCS: fn.byProp #### @ -->
* byProp

@@ -465,3 +465,3 @@ *

/**<!-- DOCS: fn.nearestTo #### -->
/**<!-- DOCS: fn.nearestTo #### @ -->
* nearestTo

@@ -487,3 +487,3 @@ *

/**<!-- DOCS: fn.furthestFrom #### -->
/**<!-- DOCS: fn.furthestFrom #### @ -->
* furthestFrom

@@ -509,3 +509,3 @@ *

/**<!-- DOCS: fn.arrayAsc #### -->
/**<!-- DOCS: fn.arrayAsc #### @ -->
* arrayAsc

@@ -530,3 +530,3 @@ *

/**<!-- DOCS: fn.arrayDesc #### -->
/**<!-- DOCS: fn.arrayDesc #### @ -->
* arrayDesc

@@ -559,3 +559,3 @@ *

/**<!-- DOCS: fn.combine #### -->
/**<!-- DOCS: fn.combine #### @ -->
* combine

@@ -579,3 +579,3 @@ *

/**<!-- DOCS: fn.combineProp #### -->
/**<!-- DOCS: fn.combineProp #### @ -->
* combineProp

@@ -602,3 +602,3 @@ *

/**<!-- DOCS: fn.mode #### -->
/**<!-- DOCS: fn.mode #### @ -->
* mode

@@ -634,3 +634,3 @@ *

/**<!-- DOCS: fn.modeMapped #### -->
/**<!-- DOCS: fn.modeMapped #### @ -->
* modeMapped

@@ -678,3 +678,3 @@ *

/**<!-- DOCS: fn.isAllEqual #### -->
/**<!-- DOCS: fn.isAllEqual #### @ -->
* isAllEqual

@@ -681,0 +681,0 @@ *

@@ -14,3 +14,3 @@ import { ArrayTools } from './ArrayTools';

/**<!-- DOCS: MathsTools.fixFloat ### -->
/**<!-- DOCS: MathsTools.fixFloat ### @ -->
* fixFloat

@@ -40,3 +40,3 @@ *

/**<!-- DOCS: MathsTools.addAll ### -->
/**<!-- DOCS: MathsTools.addAll ### @ -->
* addAll

@@ -59,3 +59,3 @@ *

*/
/**<!-- DOCS: MathsTools.floorTo #### -->
/**<!-- DOCS: MathsTools.floorTo #### @ -->
* floorTo

@@ -79,3 +79,3 @@ *

/**<!-- DOCS: MathsTools.roundTo #### -->
/**<!-- DOCS: MathsTools.roundTo #### @ -->
* roundTo

@@ -100,3 +100,3 @@ *

/**<!-- DOCS: MathsTools.ceilTo #### -->
/**<!-- DOCS: MathsTools.ceilTo #### @ -->
* ceilTo

@@ -140,3 +140,3 @@ *

/**<!-- DOCS: MathsTools.lerp ### -->
/**<!-- DOCS: MathsTools.lerp ### @ -->
* lerp

@@ -158,3 +158,3 @@ *

/**<!-- DOCS: MathsTools.lerpArray ### -->
/**<!-- DOCS: MathsTools.lerpArray ### @ -->
* lerpArray

@@ -177,3 +177,3 @@ *

/**<!-- DOCS: MathsTools.lerpObj ### -->
/**<!-- DOCS: MathsTools.lerpObj ### @ -->
* lerpObj

@@ -199,3 +199,3 @@ *

/**<!-- DOCS: MathsTools.clamp ### -->
/**<!-- DOCS: MathsTools.clamp ### @ -->
* clamp

@@ -218,3 +218,3 @@ *

/**<!-- DOCS: MathsTools.getOrdinal ### -->
/**<!-- DOCS: MathsTools.getOrdinal ### @ -->
* getOrdinal

@@ -221,0 +221,0 @@ *

@@ -12,3 +12,3 @@ import { ObjOfType, OfType } from './types';

/**<!-- DOCS: ObjectTools.remodel ### -->
/**<!-- DOCS: ObjectTools.remodel ### @ -->
* remodel

@@ -33,3 +33,3 @@ *

/**<!-- DOCS: ObjectTools.remodelEach ### -->
/**<!-- DOCS: ObjectTools.remodelEach ### @ -->
* remodelEach

@@ -56,3 +56,3 @@ *

/**<!-- DOCS: ObjectTools.map ### -->
/**<!-- DOCS: ObjectTools.map ### @ -->
* map

@@ -76,3 +76,3 @@ *

/**<!-- DOCS: ObjectTools.mapValues ### -->
/**<!-- DOCS: ObjectTools.mapValues ### @ -->
* mapValues

@@ -96,3 +96,3 @@ *

/**<!-- DOCS: ObjectTools.mapKeys ### -->
/**<!-- DOCS: ObjectTools.mapKeys ### @ -->
* mapKeys

@@ -114,3 +114,3 @@ *

/**<!-- DOCS: ObjectTools.filter ### -->
/**<!-- DOCS: ObjectTools.filter ### @ -->
* filter

@@ -132,3 +132,3 @@ *

/**<!-- DOCS: ObjectTools.clean ### -->
/**<!-- DOCS: ObjectTools.clean ### @ -->
* clean

@@ -148,3 +148,3 @@ *

/**<!-- DOCS: ObjectTools.invert ### -->
/**<!-- DOCS: ObjectTools.invert ### @ -->
* invert

@@ -151,0 +151,0 @@ *

@@ -32,3 +32,3 @@ import { fn } from './fn';

/**<!-- DOCS: progressBar.printLn ### -->
/**<!-- DOCS: progressBar.printLn ### @ -->
* printLn

@@ -185,3 +185,3 @@ *

/**<!-- DOCS: progressBar.getProgressBar ### -->
/**<!-- DOCS: progressBar.getProgressBar ### @ -->
* getProgressBar

@@ -240,4 +240,5 @@ *

* Trigger the progress bar to update/rerender
* @returns {string} The output string
*/
const update = () => {
const update = (): string => {
const suffix = getSuffix(current, maxNum, isMaxKnown, opts);

@@ -262,2 +263,3 @@ const fullPrefix = prefix.padEnd(prefixWidth);

* Set the progress bar to the next value
* @returns {string} The output string
*/

@@ -276,2 +278,4 @@ const next = (): string => {

* Set the progress bar to a specific value
* @param {number} newCurrent
* @returns {string} The output string
*/

@@ -290,2 +294,3 @@ const set = (newCurrent: number): string => {

* Set the progress bar to 0
* @returns {string} The output string
*/

@@ -302,2 +307,3 @@ const reset = (): string => {

* Start displaying the progress bar
* @returns {string} The output string
*/

@@ -315,2 +321,3 @@ const start = (): string => {

* Stop displaying the progress bar
* @returns {string} The output string
*/

@@ -317,0 +324,0 @@ const finish = (): string => {

@@ -23,3 +23,3 @@ //<!-- DOCS: 140 -->

}
/**<!-- DOCS: PromiseTools.getDeferred ### -->
/**<!-- DOCS: PromiseTools.getDeferred ### @ -->
* getDeferred

@@ -70,3 +70,3 @@ *

/**<!-- DOCS: PromiseTools.all ### -->
/**<!-- DOCS: PromiseTools.all ### @ -->
* all

@@ -85,3 +85,3 @@ *

/**<!-- DOCS: PromiseTools.allLimit ### -->
/**<!-- DOCS: PromiseTools.allLimit ### @ -->
* allLimit

@@ -175,3 +175,3 @@ *

/**<!-- DOCS: PromiseTools.each ### -->
/**<!-- DOCS: PromiseTools.each ### @ -->
* each

@@ -203,3 +203,3 @@ *

/**<!-- DOCS: PromiseTools.eachLimit ### -->
/**<!-- DOCS: PromiseTools.eachLimit ### @ -->
* eachLimit

@@ -241,3 +241,3 @@ *

/**<!-- DOCS: PromiseTools.map ### -->
/**<!-- DOCS: PromiseTools.map ### @ -->
* map

@@ -282,3 +282,3 @@ *

/**<!-- DOCS: PromiseTools.mapLimit ### -->
/**<!-- DOCS: PromiseTools.mapLimit ### @ -->
* mapLimit

@@ -331,3 +331,3 @@ *

type UnWrapPromiseObject<T> = { [K in keyof T]: UnWrapPromise<T[K]> };
/**<!-- DOCS: PromiseTools.allObj ### -->
/**<!-- DOCS: PromiseTools.allObj ### @ -->
* allObj

@@ -375,3 +375,3 @@ *

/**<!-- DOCS: PromiseTools.allLimitObj ### -->
/**<!-- DOCS: PromiseTools.allLimitObj ### @ -->
* allLimitObj

@@ -378,0 +378,0 @@ *

@@ -70,3 +70,3 @@ import { wait } from './waiters';

/**<!-- DOCS: queue.setDefaultPauseTime #### -->
/**<!-- DOCS: queue.setDefaultPauseTime #### @ -->
* setDefaultPauseTime

@@ -85,3 +85,3 @@ *

/**<!-- DOCS: queue.setPauseTime #### -->
/**<!-- DOCS: queue.setPauseTime #### @ -->
* setPauseTime

@@ -101,3 +101,3 @@ *

/**<!-- DOCS: queue.add #### -->
/**<!-- DOCS: queue.add #### @ -->
* add

@@ -126,3 +126,3 @@ *

/**<!-- DOCS: queue.new #### -->
/**<!-- DOCS: queue.new #### @ -->
* new

@@ -129,0 +129,0 @@ *

@@ -16,3 +16,3 @@ import { ObjectTools } from './ObjectTools';

/**<!-- DOCS: StringTools.capitalise ### -->
/**<!-- DOCS: StringTools.capitalise ### @ -->
* capitalise

@@ -36,3 +36,3 @@ *

/**<!-- DOCS: StringTools.angloise ### -->
/**<!-- DOCS: StringTools.angloise ### @ -->
* angloise

@@ -52,3 +52,3 @@ *

/**<!-- DOCS: StringTools.clean ### -->
/**<!-- DOCS: StringTools.clean ### @ -->
* clean

@@ -71,3 +71,3 @@ *

/**<!-- DOCS: StringTools.repeat ### -->
/**<!-- DOCS: StringTools.repeat ### @ -->
* repeat

@@ -92,6 +92,26 @@ *

type SplittingFn = (input: string | string[]) => string[];
/**<!-- DOCS: StringTools.clx ### @ -->
* clx
*
* - `clx`
* - `StringTools.clx`
*
* Composes a className from a list of strings, conditional objects and arrays.
*
* Accepts the different ways of supplying classes in AngularJS (ng-class) and returns a single string (so suitable for React).
*
* ```typescript
* clx('hello') // 'hello'
* clx('foo', 'bar') // 'foo bar'
* clx('foo', conditionA && 'bar') // 'foo'
* clx('abc', conditionB && 'def') // 'abc def'
* clx({'lorem': conditionA, 'ipsum': conditionB}) // 'ipsum'
* ```
* @param {...ClxType} [args]
* @returns {string}
*/
export const clx = (...args: ClxType[]) => processClxArray(args).join(' ');
/**<!-- DOCS: StringTools.StringCaseHandler ### -->
* StringCaseHandler
/**<!-- DOCS: StringTools.Case_Manipulators ### -->
* Case Manipulators
*/

@@ -128,2 +148,5 @@ export interface StringCaseHandler {

}
type SplittingFn = (input: string | string[]) => string[];
// SWISS-DOCS-JSDOC-REMOVE-NEXT-LINE

@@ -140,3 +163,3 @@ const caseHandler = (overrideSplitter?: SplittingFn): StringCaseHandler => {

/**<!-- DOCS: StringTools.toCamelCase #### -->
/**<!-- DOCS: StringTools.toCamelCase #### @ -->
* toCamelCase

@@ -159,3 +182,3 @@ *

};
/**<!-- DOCS: StringTools.toLowerCamelCase #### -->
/**<!-- DOCS: StringTools.toLowerCamelCase #### @ -->
* toLowerCamelCase

@@ -175,3 +198,3 @@ *

/**<!-- DOCS: StringTools.toUpperCamelCase #### -->
/**<!-- DOCS: StringTools.toUpperCamelCase #### @ -->
* toUpperCamelCase

@@ -191,3 +214,3 @@ *

/**<!-- DOCS: StringTools.toCharacterSeparated #### -->
/**<!-- DOCS: StringTools.toCharacterSeparated #### @ -->
* toCharacterSeparated

@@ -212,3 +235,3 @@ *

/**<!-- DOCS: StringTools.toSlugCase #### -->
/**<!-- DOCS: StringTools.toSlugCase #### @ -->
* toSlugCase

@@ -229,3 +252,3 @@ *

/**<!-- DOCS: StringTools.toLowerSlugCase #### -->
/**<!-- DOCS: StringTools.toLowerSlugCase #### @ -->
* toLowerSlugCase

@@ -245,3 +268,3 @@ *

/**<!-- DOCS: StringTools.toUpperSlugCase #### -->
/**<!-- DOCS: StringTools.toUpperSlugCase #### @ -->
* toUpperSlugCase

@@ -261,3 +284,3 @@ *

/**<!-- DOCS: StringTools.toSnakeCase #### -->
/**<!-- DOCS: StringTools.toSnakeCase #### @ -->
* toSnakeCase

@@ -278,3 +301,3 @@ *

/**<!-- DOCS: StringTools.toLowerSnakeCase #### -->
/**<!-- DOCS: StringTools.toLowerSnakeCase #### @ -->
* toLowerSnakeCase

@@ -294,3 +317,3 @@ *

/**<!-- DOCS: StringTools.toUpperSnakeCase #### -->
/**<!-- DOCS: StringTools.toUpperSnakeCase #### @ -->
* toUpperSnakeCase

@@ -310,3 +333,3 @@ *

/**<!-- DOCS: StringTools.toSpaced #### -->
/**<!-- DOCS: StringTools.toSpaced #### @ -->
* toSpaced

@@ -327,3 +350,3 @@ *

/**<!-- DOCS: StringTools.toLowerSpaced #### -->
/**<!-- DOCS: StringTools.toLowerSpaced #### @ -->
* toLowerSpaced

@@ -343,3 +366,3 @@ *

/**<!-- DOCS: StringTools.toUpperSpaced #### -->
/**<!-- DOCS: StringTools.toUpperSpaced #### @ -->
* toUpperSpaced

@@ -359,3 +382,3 @@ *

/**<!-- DOCS: StringTools.toCapitalisedSpaced #### -->
/**<!-- DOCS: StringTools.toCapitalisedSpaced #### @ -->
* toCapitalisedSpaced

@@ -434,3 +457,3 @@ *

/**<!-- DOCS: StringTools.fromSlugCase ### -->
/**<!-- DOCS: StringTools.fromSlugCase #### -->
* fromSlugCase

@@ -456,3 +479,3 @@ *

/**<!-- DOCS: StringTools.fromSnakeCase ### -->
/**<!-- DOCS: StringTools.fromSnakeCase #### -->
* fromSnakeCase

@@ -478,3 +501,3 @@ *

/**<!-- DOCS: StringTools.fromSpaced ### -->
/**<!-- DOCS: StringTools.fromSpaced #### -->
* fromSpaced

@@ -500,3 +523,3 @@ *

/**<!-- DOCS: StringTools.fromCamelCase ### -->
/**<!-- DOCS: StringTools.fromCamelCase #### -->
* fromCamelCase

@@ -553,24 +576,2 @@ *

/**<!-- DOCS: StringTools.clx ### -->
* clx
*
* - `clx`
* - `StringTools.clx`
*
* Composes a className from a list of strings, conditional objects and arrays.
*
* Accepts the different ways of supplying classes in AngularJS (ng-class) and returns a single string (so suitable for React).
*
* ```typescript
* clx('hello') // 'hello'
* clx('foo', 'bar') // 'foo bar'
* clx('foo', conditionA && 'bar') // 'foo'
* clx('abc', conditionB && 'def') // 'abc def'
* clx({'lorem': conditionA, 'ipsum': conditionB}) // 'ipsum'
* ```
* @param {...ClxType} [args]
* @returns {string}
*/
export const clx = (...args: ClxType[]) => processClxArray(args).join(' ');
/**<!-- DOCS: StringTools.matchBrackets ### -->

@@ -662,3 +663,3 @@ * matchBrackets

/**<!-- DOCS: StringTools.matchBrackets.unique #### -->
/**<!-- DOCS: StringTools.matchBrackets.unique #### @ -->
* unique

@@ -681,3 +682,3 @@ *

/**<!-- DOCS: StringTools.matchBrackets.depth #### -->
/**<!-- DOCS: StringTools.matchBrackets.depth #### @ -->
* depth

@@ -700,3 +701,3 @@ *

/**<!-- DOCS: StringTools.matchBrackets.clean #### -->
/**<!-- DOCS: StringTools.matchBrackets.clean #### @ -->
* clean

@@ -762,3 +763,3 @@ *

/**<!-- DOCS: StringTools.matchBrackets.grabDepth #### -->
/**<!-- DOCS: StringTools.matchBrackets.grabDepth #### @ -->
* grabDepth

@@ -800,3 +801,3 @@ *

/**<!-- DOCS: StringTools.matchBrackets.grabUnique #### -->
/**<!-- DOCS: StringTools.matchBrackets.grabUnique #### @ -->
* grabUnique

@@ -839,3 +840,3 @@ *

/**<!-- DOCS: StringTools.matchBrackets.grab #### -->
/**<!-- DOCS: StringTools.matchBrackets.grab #### @ -->
* grab

@@ -883,3 +884,3 @@ *

/**<!-- DOCS: StringTools.matchBrackets.getReplaceSymbols #### -->
/**<!-- DOCS: StringTools.matchBrackets.getReplaceSymbols #### @ -->
* getReplaceSymbols

@@ -886,0 +887,0 @@ *

@@ -152,3 +152,3 @@ //<!-- DOCS: 700 -->

/**<!-- DOCS: superscript ### -->
/**<!-- DOCS: superscript ### @ -->
* superscript

@@ -155,0 +155,0 @@ *

@@ -48,3 +48,3 @@ import { ms } from './times';

/**<!-- DOCS: timer.getTimer ### -->
/**<!-- DOCS: timer.getTimer ### @ -->
* getTimer

@@ -51,0 +51,0 @@ *

@@ -266,3 +266,3 @@ /**<!-- DOCS: times ##! 10 -->

/**<!-- DOCS: times.milliseconds ### -1 -->
/**<!-- DOCS: times.milliseconds ### -1 @ -->
* milliseconds

@@ -286,3 +286,3 @@ *

/**<!-- DOCS: times.seconds ### -1 -->
/**<!-- DOCS: times.seconds ### -1 @ -->
* seconds

@@ -306,3 +306,3 @@ *

/**<!-- DOCS: times.minutes ### -1 -->
/**<!-- DOCS: times.minutes ### -1 @ -->
* minutes

@@ -326,3 +326,3 @@ *

/**<!-- DOCS: times.hours ### -1 -->
/**<!-- DOCS: times.hours ### -1 @ -->
* hours

@@ -346,3 +346,3 @@ *

/**<!-- DOCS: times.days ### -1 -->
/**<!-- DOCS: times.days ### -1 @ -->
* days

@@ -366,3 +366,3 @@ *

/**<!-- DOCS: times.weeks ### -1 -->
/**<!-- DOCS: times.weeks ### -1 @ -->
* weeks

@@ -386,3 +386,3 @@ *

/**<!-- DOCS: times.months ### -1 -->
/**<!-- DOCS: times.months ### -1 @ -->
* months

@@ -406,3 +406,3 @@ *

/**<!-- DOCS: times.years ### -1 -->
/**<!-- DOCS: times.years ### -1 @ -->
* years

@@ -426,3 +426,3 @@ *

/**<!-- DOCS: times.decades ### -1 -->
/**<!-- DOCS: times.decades ### -1 @ -->
* decades

@@ -446,3 +446,3 @@ *

/**<!-- DOCS: times.centuries ### -1 -->
/**<!-- DOCS: times.centuries ### -1 @ -->
* centuries

@@ -466,3 +466,3 @@ *

/**<!-- DOCS: times.millenniums ### -1 -->
/**<!-- DOCS: times.millenniums ### -1 @ -->
* millenniums

@@ -469,0 +469,0 @@ *

@@ -71,3 +71,3 @@ import { ms, MILLISECOND, SECOND, MINUTE, HOUR, DAY, MONTH, YEAR, CENTURY, MILLENNIUM } from './times';

/**<!-- DOCS: TimeTools.toReadableDuration ### -->
/**<!-- DOCS: TimeTools.toReadableDuration ### @ -->
* toReadableDuration

@@ -74,0 +74,0 @@ *

@@ -23,3 +23,3 @@ import { ms } from './times';

/**<!-- DOCS: waiters.wait ### -->
/**<!-- DOCS: waiters.wait ### @ -->
* wait

@@ -49,3 +49,3 @@ *

/**<!-- DOCS: waiters.waitUntil ### -->
/**<!-- DOCS: waiters.waitUntil ### @ -->
* waitUntil

@@ -75,3 +75,3 @@ *

/**<!-- DOCS: waiters.waitFor ### -->
/**<!-- DOCS: waiters.waitFor ### @ -->
* waitFor

@@ -103,3 +103,3 @@ *

/**<!-- DOCS: waiters.waitEvery ### -->
/**<!-- DOCS: waiters.waitEvery ### @ -->
* waitEvery

@@ -126,3 +126,3 @@ *

const stopped: number[] = [];
/**<!-- DOCS: waiters.stopInterval ### -->
/**<!-- DOCS: waiters.stopInterval ### @ -->
* stopInterval

@@ -149,3 +149,3 @@ *

/**<!-- DOCS: waiters.interval ### -->
/**<!-- DOCS: waiters.interval ### @ -->
* interval

@@ -152,0 +152,0 @@ *

@@ -123,2 +123,78 @@ import * as swissak from '../';

describe('findAndRemove', () => {
it(`exists as 'ArrayTools.findAndRemove'`, () => {
expect(swissak.ArrayTools.findAndRemove).toBeDefined();
});
it(`finds the correct item and remove it`, () => {
const array = [1, 2, 999, 4, 5, 6, 7, 8, 999, 0];
const result = swissak.ArrayTools.findAndRemove(array, (item) => item === 999);
expect(result).toBe(999);
expect(array).toEqual([1, 2, 4, 5, 6, 7, 8, 999, 0]);
});
it(`returns undefined if not found`, () => {
const array = [1, 2, 999, 4, 5, 6, 7, 8, 999, 0];
const result = swissak.ArrayTools.findAndRemove(array, (item) => item === 666);
expect(result).toBeUndefined();
expect(array).toEqual([1, 2, 999, 4, 5, 6, 7, 8, 999, 0]);
});
it(`inserts provided items in place of removed items`, () => {
const array = [1, 2, 999, 4, 5, 6, 7, 8, 999, 0];
const result = swissak.ArrayTools.findAndRemove(array, (item) => item === 999, 111, 222, 333);
expect(result).toBe(999);
expect(array).toEqual([1, 2, 111, 222, 333, 4, 5, 6, 7, 8, 999, 0]);
});
it(`ignores insertItems if nothing found`, () => {
const array = [1, 2, 999, 4, 5, 6, 7, 8, 999, 0];
const result = swissak.ArrayTools.findAndRemove(array, (item) => item === 666, 111, 222, 333);
expect(result).toBeUndefined();
expect(array).toEqual([1, 2, 999, 4, 5, 6, 7, 8, 999, 0]);
});
});
describe('findLastAndRemove', () => {
it(`exists as 'ArrayTools.findLastAndRemove'`, () => {
expect(swissak.ArrayTools.findLastAndRemove).toBeDefined();
});
it(`finds the correct item and remove it`, () => {
const array = [1, 2, 999, 4, 5, 6, 7, 8, 999, 0];
const result = swissak.ArrayTools.findLastAndRemove(array, (item) => item === 999);
expect(result).toBe(999);
expect(array).toEqual([1, 2, 999, 4, 5, 6, 7, 8, 0]);
});
it(`returns undefined if not found`, () => {
const array = [1, 2, 999, 4, 5, 6, 7, 8, 999, 0];
const result = swissak.ArrayTools.findLastAndRemove(array, (item) => item === 666);
expect(result).toBeUndefined();
expect(array).toEqual([1, 2, 999, 4, 5, 6, 7, 8, 999, 0]);
});
it(`inserts provided items in place of removed items`, () => {
const array = [1, 2, 999, 4, 5, 6, 7, 8, 999, 0];
const result = swissak.ArrayTools.findLastAndRemove(array, (item) => item === 999, 111, 222, 333);
expect(result).toBe(999);
expect(array).toEqual([1, 2, 999, 4, 5, 6, 7, 8, 111, 222, 333, 0]);
});
it(`ignores insertItems if nothing found`, () => {
const array = [1, 2, 999, 4, 5, 6, 7, 8, 999, 0];
const result = swissak.ArrayTools.findLastAndRemove(array, (item) => item === 666, 111, 222, 333);
expect(result).toBeUndefined();
expect(array).toEqual([1, 2, 999, 4, 5, 6, 7, 8, 999, 0]);
});
});
describe('filterAndRemove', () => {
it(`exists as 'ArrayTools.filterAndRemove'`, () => {
expect(swissak.ArrayTools.filterAndRemove).toBeDefined();
});
it(`finds the correct item and remove it`, () => {
const array = [1, 2, 999, 4, 5, 6, 7, 8, 999, 0];
const result = swissak.ArrayTools.filterAndRemove(array, (item) => item === 999);
expect(result).toEqual([999, 999]);
expect(array).toEqual([1, 2, 4, 5, 6, 7, 8, 0]);
});
it(`returns empty array if not found`, () => {
const array = [1, 2, 999, 4, 5, 6, 7, 8, 999, 0];
const result = swissak.ArrayTools.filterAndRemove(array, (item) => item === 666);
expect(result).toEqual([]);
expect(array).toEqual([1, 2, 999, 4, 5, 6, 7, 8, 999, 0]);
});
});
describe('utils', () => {

@@ -125,0 +201,0 @@ it(`exists as 'ArrayTools.utils'`, () => {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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