@ixfx/process 0.38.0 → 0.39.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/README.md ADDED
@@ -0,0 +1,17 @@
1
+ The process module contains functions for orchestrating a simple series of data transformations.
2
+
3
+ Use `flow` to create this orchestration:
4
+
5
+ ```js
6
+ const p = flow(
7
+ (value:string) => value.toUpperCase(), // Convert to uppercase
8
+ (value:string) => value.at(0) === 'A') // If first letter is an A, return true
9
+ );
10
+ ```
11
+
12
+ Once created, the flow can be invoked with an input value:
13
+ ```js
14
+ p('apple'); // True
15
+ ```
16
+
17
+ Each function in the processing flow takes one input and returns one result. There are a few in-built functions as well. Some of these are stateful, remembering previous values that have been processed (eg `seenToUndefined`).
@@ -1,4 +1,3 @@
1
- /**
2
1
  /**
3
2
  * Calls a function if the input value is not undefined.
4
3
  * Return value from function is passed to next function in flow.
@@ -1 +1 @@
1
- {"version":3,"file":"if-undefined.d.ts","sourceRoot":"","sources":["../../src/if-undefined.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,EAAE,SAAS,CAAC,KAAK,IAAI,IAC5E,OAAO,GAAG,gBAKnB;AAID;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,MAC3B,OAAO,GAAG,GAAG,SAAS,KAEZ,GAAG,CAEtB;AACD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,IAAI,IAC3C,OAAO,GAAG,gCAInB"}
1
+ {"version":3,"file":"if-undefined.d.ts","sourceRoot":"","sources":["../../src/if-undefined.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,EAAE,SAAS,CAAC,KAAK,IAAI,IAC5E,OAAO,GAAG,gBAKnB;AAID;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,MAC3B,OAAO,GAAG,GAAG,SAAS,KAEZ,GAAG,CAEtB;AACD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,IAAI,IAC3C,OAAO,GAAG,gCAInB"}
@@ -1,5 +1,4 @@
1
1
  import { CancelError } from "./cancel-error.js";
2
- /**
3
2
  /**
4
3
  * Calls a function if the input value is not undefined.
5
4
  * Return value from function is passed to next function in flow.
@@ -1,12 +1,14 @@
1
1
  import type { Process } from "./types.js";
2
2
  /**
3
3
  * If a value is same as the previous value, _undefined_ is emitted instead.
4
+ *
4
5
  * @param eq Equality function. If not specified, === semantics are used.
5
6
  * @returns
6
7
  */
7
8
  export declare function seenLastToUndefined<TIn>(eq?: (a: TIn, b: TIn) => boolean): Process<TIn, TIn | undefined>;
8
9
  /**
9
10
  * If a value is same as any previously-seen value, _undefined_ is emitted instead.
11
+ *
10
12
  * It stores all previous values and compares against them for each new value.
11
13
  * This would likely be not very efficient compared to {@link seenToUndefinedByKey} which uses a one-time computed
12
14
  * key and efficient storage of only the keys (using a Set).
@@ -17,6 +19,7 @@ export declare function seenLastToUndefined<TIn>(eq?: (a: TIn, b: TIn) => boolea
17
19
  export declare function seenToUndefined<TIn>(eq?: (a: TIn, b: TIn) => boolean): Process<TIn, TIn | undefined>;
18
20
  /**
19
21
  * If a value is the same as any previously-seen value, _undefined_ is emitted instead.
22
+ *
20
23
  * This version uses a function to create a string key of the object, by default JSON.stringify.
21
24
  * Thus we don't need to store all previously seen objects, just their keys.
22
25
  *
@@ -1 +1 @@
1
- {"version":3,"file":"seen.d.ts","sourceRoot":"","sources":["../../src/seen.ts"],"names":[],"mappings":"AAAA,O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AE,GAAG,KAAK,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,SAAS,CAAC,CAU1G"}
package/dist/src/seen.js CHANGED
@@ -1,11 +1,12 @@
1
1
  import { isEqualDefault, toStringDefault } from "./util.js";
2
2
  /**
3
3
  * If a value is same as the previous value, _undefined_ is emitted instead.
4
+ *
4
5
  * @param eq Equality function. If not specified, === semantics are used.
5
6
  * @returns
6
7
  */
7
8
  export function seenLastToUndefined(eq) {
8
- if (eq === undefined)
9
+ if (typeof eq === `undefined`)
9
10
  eq = isEqualDefault;
10
11
  let lastValue;
11
12
  return (value) => {
@@ -18,6 +19,7 @@ export function seenLastToUndefined(eq) {
18
19
  }
19
20
  /**
20
21
  * If a value is same as any previously-seen value, _undefined_ is emitted instead.
22
+ *
21
23
  * It stores all previous values and compares against them for each new value.
22
24
  * This would likely be not very efficient compared to {@link seenToUndefinedByKey} which uses a one-time computed
23
25
  * key and efficient storage of only the keys (using a Set).
@@ -26,8 +28,8 @@ export function seenLastToUndefined(eq) {
26
28
  * @returns
27
29
  */
28
30
  export function seenToUndefined(eq) {
29
- let seen = [];
30
- if (eq === undefined)
31
+ const seen = [];
32
+ if (typeof eq === `undefined`)
31
33
  eq = isEqualDefault;
32
34
  return (value) => {
33
35
  if (value === undefined)
@@ -42,6 +44,7 @@ export function seenToUndefined(eq) {
42
44
  }
43
45
  /**
44
46
  * If a value is the same as any previously-seen value, _undefined_ is emitted instead.
47
+ *
45
48
  * This version uses a function to create a string key of the object, by default JSON.stringify.
46
49
  * Thus we don't need to store all previously seen objects, just their keys.
47
50
  *
@@ -52,8 +55,8 @@ export function seenToUndefined(eq) {
52
55
  * @returns
53
56
  */
54
57
  export function seenToUndefinedByKey(toString) {
55
- let seen = new Set();
56
- if (toString === undefined)
58
+ const seen = new Set();
59
+ if (typeof toString === `undefined`)
57
60
  toString = toStringDefault;
58
61
  return (value) => {
59
62
  if (value === undefined)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ixfx/process",
3
- "version": "0.38.0",
3
+ "version": "0.39.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,