shelving 1.108.3 → 1.108.5

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/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "state-management",
12
12
  "query-builder"
13
13
  ],
14
- "version": "1.108.3",
14
+ "version": "1.108.5",
15
15
  "repository": "https://github.com/dhoulb/shelving",
16
16
  "author": "Dave Houlbrooke <dave@shax.com>",
17
17
  "license": "0BSD",
@@ -20,7 +20,7 @@ export type StopCallback = () => void;
20
20
  /** Safely call a callback function (possibly with a value). */
21
21
  export declare function call<A extends Arguments = []>(callback: (...v: A) => unknown, ...values: A): void;
22
22
  /** Return a callback function that safely calls a callback function (possibly with a value). */
23
- export declare function called<T>(dispatcher: AsyncValueCallback<T>): ValueCallback<T>;
23
+ export declare function called<A extends Arguments = []>(dispatcher: (...v: A) => unknown, ...values: A): Callback;
24
24
  /** Safely call a callback method (possibly wth a value). */
25
25
  export declare function callMethod<A extends Arguments, M extends string | symbol>(obj: {
26
26
  [K in M]?: ((...v: A) => unknown) | undefined;
package/util/callback.js CHANGED
@@ -12,8 +12,8 @@ export function call(callback, ...values) {
12
12
  }
13
13
  }
14
14
  /** Return a callback function that safely calls a callback function (possibly with a value). */
15
- export function called(dispatcher) {
16
- return (value) => call(dispatcher, value);
15
+ export function called(dispatcher, ...values) {
16
+ return () => call(dispatcher, ...values);
17
17
  }
18
18
  /** Safely call a callback method (possibly wth a value). */
19
19
  export function callMethod(obj, key, ...values) {
package/util/string.d.ts CHANGED
@@ -82,6 +82,8 @@ export declare function getRef(str: string): string;
82
82
  * Note: this splits words based on spaces, so won't work well with logographic writing systems e.g. kanji.
83
83
  */
84
84
  export declare const getWords: (str: string) => ImmutableArray<string>;
85
+ /** Get the (trimmed) first full line of a string. */
86
+ export declare function getFirstLine(str: string): string;
85
87
  /** Is the first character of a string an uppercase letter? */
86
88
  export declare const isUppercaseLetter: (str: string) => boolean;
87
89
  /** Is the first character of a string a lowercase letter? */
package/util/string.js CHANGED
@@ -142,6 +142,11 @@ function* _getWords(str) {
142
142
  }
143
143
  }
144
144
  const WORD = /([^\s"]+)|"([^"]*)"|'([^']*)'/g; // Runs of characters without spaces, or "quoted phrases"
145
+ /** Get the (trimmed) first full line of a string. */
146
+ export function getFirstLine(str) {
147
+ const i = str.indexOf("\n");
148
+ return (i >= 0 ? str.substr(0, i) : str).trim();
149
+ }
145
150
  /** Is the first character of a string an uppercase letter? */
146
151
  export const isUppercaseLetter = (str) => isBetween(str.charCodeAt(0), 65, 90);
147
152
  /** Is the first character of a string a lowercase letter? */