linked-rolls 0.43.0 → 0.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/utils.d.ts CHANGED
@@ -14,6 +14,8 @@ export type WithId = {
14
14
  };
15
15
  /** Whether a value is a date as the format writes one, `YYYY-MM-DD`. */
16
16
  export declare const isDateString: (value: unknown) => value is string;
17
+ /** The items by the key each of them gives, every group in the order its first item came in. */
18
+ export declare const groupBy: <T>(items: readonly T[], keyOf: (item: T) => string) => Map<string, T[]>;
17
19
  export type WithNote = {
18
20
  /**
19
21
  * A free-text note providing additional context.
package/lib/utils.js CHANGED
@@ -1,2 +1,12 @@
1
1
  /** Whether a value is a date as the format writes one, `YYYY-MM-DD`. */
2
2
  export const isDateString = (value) => typeof value === 'string' && /^\d{4}-\d{1,2}-\d{1,2}$/.test(value);
3
+ /** The items by the key each of them gives, every group in the order its first item came in. */
4
+ export const groupBy = (items, keyOf) => items.reduce((groups, item) => {
5
+ const key = keyOf(item);
6
+ const group = groups.get(key);
7
+ if (group)
8
+ group.push(item);
9
+ else
10
+ groups.set(key, [item]);
11
+ return groups;
12
+ }, new Map());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linked-rolls",
3
- "version": "0.43.0",
3
+ "version": "0.44.0",
4
4
  "description": "Digital editions of piano rolls: import, collation, editorial assumptions, JSON-LD export, and emulation through a reproducing system",
5
5
  "license": "MIT",
6
6
  "repository": {