@oliversalzburg/js-utils 0.0.24-dev.26 → 0.0.24-dev.28

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@oliversalzburg/js-utils",
4
- "version": "0.0.24-dev.26",
4
+ "version": "0.0.24-dev.28",
5
5
  "license": "MIT",
6
6
  "author": "Oliver Salzburg <oliver.salzburg@gmail.com>",
7
7
  "repository": {
@@ -36,8 +36,8 @@
36
36
  "@types/mocha": "10.0.6",
37
37
  "@types/node": "20.10.3",
38
38
  "@types/web": "0.0.125",
39
- "@typescript-eslint/eslint-plugin": "6.13.1",
40
- "@typescript-eslint/parser": "6.13.1",
39
+ "@typescript-eslint/eslint-plugin": "6.13.2",
40
+ "@typescript-eslint/parser": "6.13.2",
41
41
  "c8": "8.0.1",
42
42
  "chai": "4.3.10",
43
43
  "chai-as-promised": "7.1.1",
package/string.d.ts CHANGED
@@ -1,9 +1,20 @@
1
1
  /**
2
2
  * Indent every line of the passed text.
3
- * @param text - The text to indent.
3
+ * @param subject - The text to indent.
4
4
  * @param depth - How often to apply the indenting.
5
5
  * @param prefix - The string to use as the indent.
6
6
  * @returns The indented text.
7
7
  * @group Strings
8
8
  */
9
- export declare const indent: (text: string, depth?: number, prefix?: string) => string;
9
+ export declare const indent: (subject: string, depth?: number, prefix?: string) => string;
10
+ /**
11
+ * A fast and simple 53-bit string hash function with decent collision resistance.
12
+ * Largely inspired by MurmurHash2/3, but with a focus on speed/simplicity.
13
+ * License: Public domain. Attribution appreciated.
14
+ * cyrb53 (c) 2018 bryc (github.com/bryc)
15
+ * @param subject - The string to hash.
16
+ * @param seed - An optional seed value.
17
+ * @returns A hash of the string.
18
+ * @group Strings
19
+ */
20
+ export declare const cyrb53: (subject: string, seed?: number) => string;
package/string.js CHANGED
@@ -1,10 +1,33 @@
1
1
  /**
2
2
  * Indent every line of the passed text.
3
- * @param text - The text to indent.
3
+ * @param subject - The text to indent.
4
4
  * @param depth - How often to apply the indenting.
5
5
  * @param prefix - The string to use as the indent.
6
6
  * @returns The indented text.
7
7
  * @group Strings
8
8
  */
9
- export const indent = (text, depth = 0, prefix = " ") => text.replaceAll(/^/gm, prefix.repeat(depth));
9
+ export const indent = (subject, depth = 0, prefix = " ") => subject.replaceAll(/^/gm, prefix.repeat(depth));
10
+ /**
11
+ * A fast and simple 53-bit string hash function with decent collision resistance.
12
+ * Largely inspired by MurmurHash2/3, but with a focus on speed/simplicity.
13
+ * License: Public domain. Attribution appreciated.
14
+ * cyrb53 (c) 2018 bryc (github.com/bryc)
15
+ * @param subject - The string to hash.
16
+ * @param seed - An optional seed value.
17
+ * @returns A hash of the string.
18
+ * @group Strings
19
+ */
20
+ export const cyrb53 = (subject, seed = 0) => {
21
+ let h1 = 0xdeadbeef ^ seed, h2 = 0x41c6ce57 ^ seed;
22
+ for (let i = 0, ch; i < subject.length; i++) {
23
+ ch = subject.charCodeAt(i);
24
+ h1 = Math.imul(h1 ^ ch, 2654435761);
25
+ h2 = Math.imul(h2 ^ ch, 1597334677);
26
+ }
27
+ h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507);
28
+ h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909);
29
+ h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507);
30
+ h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909);
31
+ return (h2 >>> 0).toString(16).padStart(8, "0") + (h1 >>> 0).toString(16).padStart(8, "0");
32
+ };
10
33
  //# sourceMappingURL=string.js.map
package/string.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"string.js","sourceRoot":"","sources":["../source/string.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,IAAY,EAAE,KAAK,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,EAA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