@ts-common/string-map
Advanced tools
Comparing version 0.0.2 to 0.0.3
export interface StringMap<T> { | ||
readonly [key: string]: T; | ||
} | ||
export declare type Entry<T> = Readonly<[string, T]>; | ||
export declare const enum EntryIndex { | ||
Name = 0, | ||
Value = 1 | ||
} | ||
export interface Entry<T> { | ||
readonly [EntryIndex.Name]: string; | ||
readonly [EntryIndex.Value]: T; | ||
/** | ||
* The property is required for destruction. | ||
*/ | ||
readonly [Symbol.iterator]: () => IterableIterator<string | T>; | ||
} | ||
export declare function entries<T>(input: StringMap<T | undefined>): Iterable<Entry<T>>; | ||
@@ -9,6 +20,2 @@ export declare function names<T>(input: StringMap<T>): Iterable<string>; | ||
export declare function entry<T>(name: string, value: T): Entry<T>; | ||
export declare const enum EntryIndex { | ||
Name = 0, | ||
Value = 1 | ||
} | ||
export declare function entryName<T>(e: Entry<T>): string; | ||
@@ -15,0 +22,0 @@ export declare function entryValue<T>(e: Entry<T>): T; |
13
index.js
@@ -7,2 +7,3 @@ "use strict"; | ||
function* iterator() { | ||
/* tslint:disable-next-line:no-loop-statement */ | ||
for (const name in input) { | ||
@@ -42,9 +43,7 @@ const value = input[name]; | ||
const result = {}; | ||
for (const nv of input) { | ||
const n = entryName(nv); | ||
const v = entryValue(nv); | ||
const prior = result[n]; | ||
i.forEach(input, ([name, value]) => { | ||
const prior = result[name]; | ||
/* tslint:disable-next-line:no-object-mutation no-expression-statement */ | ||
result[n] = prior === undefined ? v : reduceFunc(prior, v); | ||
} | ||
result[name] = prior === undefined ? value : reduceFunc(prior, value); | ||
}); | ||
return result; | ||
@@ -54,4 +53,4 @@ } | ||
function stringMap(input) { | ||
return groupBy(input, a => a); | ||
return groupBy(input, v => v); | ||
} | ||
exports.stringMap = stringMap; |
{ | ||
"name": "@ts-common/string-map", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "", | ||
@@ -36,4 +36,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"@ts-common/iterator": "0.0.20" | ||
"@ts-common/iterator": "0.0.21" | ||
} | ||
} |
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
15068
76
+ Added@ts-common/iterator@0.0.21(transitive)
- Removed@ts-common/iterator@0.0.20(transitive)
Updated@ts-common/iterator@0.0.21