@vyacheslav97/ct
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -15,1 +15,3 @@ import { ValueExtractor, DuplicateData } from '../../interfaces/index.js'; | ||
export declare const buildDuplicatesSearcher: <T, V = T>(valueExtractor?: ValueExtractor<T, V>) => (source: Iterable<T>) => Map<V, DuplicateData<T>[]>; | ||
export declare const groupByKey: <T, V = T>(source: Iterable<T>, valueExtractor?: ValueExtractor<T, V>) => Map<V, DuplicateData<T>[]>; | ||
export declare const buildGroupByKey: <T, V = T>(valueExtractor?: ValueExtractor<T, V>) => (source: Iterable<T>) => Map<V, DuplicateData<T>[]>; |
@@ -30,1 +30,5 @@ /** | ||
}; | ||
// <u>**duplicatesSearcher**</u> function alias | ||
export const groupByKey = duplicatesSearcher; | ||
// <u>**buildDuplicatesSearcher**</u> function alias | ||
export const buildGroupByKey = buildDuplicatesSearcher; |
export * from './binarySearch'; | ||
export * from './duplicatesSearcher'; | ||
export * from './uniqueValuesSearcher'; |
export * from './binarySearch'; | ||
export * from './duplicatesSearcher'; | ||
export * from './uniqueValuesSearcher'; |
@@ -1,4 +0,9 @@ | ||
import { SingleToSingle, SingleToPair, PairToSingle } from '../../interfaces/index.js'; | ||
import { SingleToSingle, SingleToPair, PairToSingle, PairToPair } from '../../interfaces/index.js'; | ||
/**********************************************************************************************************************/ | ||
/** | ||
* Creates <u>**Array**</u> to <u>**Array**</u> converter | ||
* @param arrayItemTransformer <u>**Array**</u> item transformer, produces a new array item | ||
*/ | ||
export declare function createArrayToArray<SourceArrayItem, TargetArrayItem>(arrayItemTransformer: SingleToSingle<SourceArrayItem, TargetArrayItem>): (sourceIterable: SourceArrayItem[]) => TargetArrayItem[]; | ||
/** | ||
* Creates <u>**Array**</u> to <u>**Map**</u> converter | ||
@@ -20,2 +25,7 @@ * @param arrayItemTransformer <u>**Array**</u> item transformer, derives key-value pair from array item | ||
/** | ||
* Creates <u>**Map**</u> to <u>**Map**</u> converter | ||
* @param mapItemTransformer <u>**Map**</u> item transformer, retrieves a new map item | ||
*/ | ||
export declare function createMapToMap<K1, V1, K2, V2>(mapItemTransformer: PairToPair<K1, V1, K2, V2>): (sourceIterable: Map<K1, V1>) => Map<K2, V2>; | ||
/** | ||
* Creates <u>**Map**</u> to <u>**Array**</u> converter | ||
@@ -37,2 +47,7 @@ * @param mapItemTransformer <u>**Map**</u> item transformer, retrieves Array item from Map item | ||
/** | ||
* Creates <u>**Set**</u> to <u>**Set**</u> converter | ||
* @param setItemTransformer **Set** item transformer, forms a Set item out Set item | ||
*/ | ||
export declare function createSetToSet<SourceSetItem, TargetSetItem>(setItemTransformer: SingleToSingle<SourceSetItem, TargetSetItem>): (sourceIterable: Set<SourceSetItem>) => Set<TargetSetItem>; | ||
/** | ||
* Creates <u>**Set**</u> to <u>**Array**</u> converter | ||
@@ -54,4 +69,9 @@ * @param setItemTransformer **Set** item transformer, forms an Array item out Set item | ||
/** | ||
* Creates <u>**string**</u> to <u>**string**</u> converter | ||
* @param characterTransformer character transformer, forms string item out a character | ||
*/ | ||
export declare function createStringToString(characterTransformer?: SingleToSingle<string, string>): (sourceIterable: string) => string; | ||
/** | ||
* Creates <u>**string**</u> to <u>**Array**</u> converter | ||
* @param characterTransformer character transformer, forms Array item out character | ||
* @param characterTransformer character transformer, forms Array item out a character | ||
*/ | ||
@@ -61,3 +81,3 @@ export declare function createStringToArray<ArrayItemType>(characterTransformer?: SingleToSingle<string, ArrayItemType>): (sourceIterable: string) => ArrayItemType[]; | ||
* Creates <u>**string**</u> to <u>**Map**</u> converter | ||
* @param characterTransformer character transformer, forms Map item out character | ||
* @param characterTransformer character transformer, forms Map item out a character | ||
*/ | ||
@@ -67,4 +87,4 @@ export declare function createStringToMap<K, V>(characterTransformer: SingleToPair<string, K, V>): (sourceIterable: string) => Map<K, V>; | ||
* Creates <u>**string**</u> to <u>**Set**</u> converter | ||
* @param characterTransformer character transformer, forms Set item out character | ||
* @param characterTransformer character transformer, forms Set item out a character | ||
*/ | ||
export declare function createStringToSet<SetItemType>(characterTransformer?: SingleToSingle<string, SetItemType>): (sourceIterable: string) => Set<SetItemType>; |
@@ -6,2 +6,9 @@ // UIC Standard Data Structures (UICSDS) | ||
/** | ||
* Creates <u>**Array**</u> to <u>**Array**</u> converter | ||
* @param arrayItemTransformer <u>**Array**</u> item transformer, produces a new array item | ||
*/ | ||
export function createArrayToArray(arrayItemTransformer) { | ||
return createIterableTransformer(Array, arrayItemTransformer); | ||
} | ||
/** | ||
* Creates <u>**Array**</u> to <u>**Map**</u> converter | ||
@@ -31,2 +38,9 @@ * @param arrayItemTransformer <u>**Array**</u> item transformer, derives key-value pair from array item | ||
/** | ||
* Creates <u>**Map**</u> to <u>**Map**</u> converter | ||
* @param mapItemTransformer <u>**Map**</u> item transformer, retrieves a new map item | ||
*/ | ||
export function createMapToMap(mapItemTransformer) { | ||
return createIterableTransformer(Map, mapItemTransformer); | ||
} | ||
/** | ||
* Creates <u>**Map**</u> to <u>**Array**</u> converter | ||
@@ -56,2 +70,9 @@ * @param mapItemTransformer <u>**Map**</u> item transformer, retrieves Array item from Map item | ||
/** | ||
* Creates <u>**Set**</u> to <u>**Set**</u> converter | ||
* @param setItemTransformer **Set** item transformer, forms a Set item out Set item | ||
*/ | ||
export function createSetToSet(setItemTransformer) { | ||
return createIterableTransformer(Set, setItemTransformer); | ||
} | ||
/** | ||
* Creates <u>**Set**</u> to <u>**Array**</u> converter | ||
@@ -81,4 +102,12 @@ * @param setItemTransformer **Set** item transformer, forms an Array item out Set item | ||
/** | ||
* Creates <u>**string**</u> to <u>**string**</u> converter | ||
* @param characterTransformer character transformer, forms string item out a character | ||
*/ | ||
export function createStringToString(characterTransformer) { | ||
//@ts-ignore | ||
return createIterableTransformer(String, characterTransformer); | ||
} | ||
/** | ||
* Creates <u>**string**</u> to <u>**Array**</u> converter | ||
* @param characterTransformer character transformer, forms Array item out character | ||
* @param characterTransformer character transformer, forms Array item out a character | ||
*/ | ||
@@ -90,3 +119,3 @@ export function createStringToArray(characterTransformer) { | ||
* Creates <u>**string**</u> to <u>**Map**</u> converter | ||
* @param characterTransformer character transformer, forms Map item out character | ||
* @param characterTransformer character transformer, forms Map item out a character | ||
*/ | ||
@@ -98,3 +127,3 @@ export function createStringToMap(characterTransformer) { | ||
* Creates <u>**string**</u> to <u>**Set**</u> converter | ||
* @param characterTransformer character transformer, forms Set item out character | ||
* @param characterTransformer character transformer, forms Set item out a character | ||
*/ | ||
@@ -101,0 +130,0 @@ export function createStringToSet(characterTransformer) { |
@@ -8,1 +8,2 @@ /*********************************************************************************************************************/ | ||
export type PairToSingle<K, V, S> = ValueTransformer<[K, V], S>; | ||
export type PairToPair<S1, S2, T1, T2> = ValueTransformer<[S1, S2], [T1, T2]>; |
{ | ||
"name": "@vyacheslav97/ct", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -9,6 +9,7 @@ # <u>Common tools (ct, also @vyacheslav97/ct)</u> | ||
Current version renewals (1.0.3) (see **Prerequesites** a bit below): | ||
Current version renewals (1.0.4) (see **Prerequesites** a bit below): | ||
- Imports huge bug fix (webpack and the rest became unable to assemble package due to type: module) | ||
- **ErrorWithData** template class | ||
- Added several extra iterable converters: **createMapToMap**, **createArrayToArray**, **createSetToSet**, **createStringToString** | ||
- Added two aliases, **groupByKey**, **groupByKey** for duplicates searcher procedure | ||
- **uniqueValuesSearcher** procedure was implemented (see below) | ||
@@ -34,2 +35,3 @@ Next scheduled **major** updates: | ||
- [Duplicates search procedure template](#duplicatesSearch) | ||
- [Unique values search procedure template](#uniqueValuesSearch) | ||
- [isNumber](#isNumber) | ||
@@ -623,2 +625,23 @@ - [Decimal integer RegExp](#integerRegExp) | ||
<a id="uniqueValuesSearch"></a> | ||
## Unique values search procedure template | ||
**Unique values search** procedure template import: | ||
```ts | ||
import { | ||
uniqueValuesSearcher, | ||
createUniqueValuesSearcher, | ||
} from '@vyacheslav97/ct'; | ||
``` | ||
**uniqueValuesSearcher** accepts a uniform array and filters unique values out of it. This function requires two arguments: | ||
- **sourceArray** - source array to filter unique values out of it | ||
- **uniqueFeatureValueExtractor** - a function, that derives a value of uniqueness feature (according to this value two objects are considered as identical) | ||
It is recommended to use **createUniqueValuesSearcher** over **uniqueValuesSearcher**. **createUniqueValuesSearcher** creates an instance of **uniqueValuesSearcher** using a particular uniqueness feature value extractor function | ||
<a id="isNumber"></a> | ||
@@ -625,0 +648,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
80860
76
1256
731