@terascope/core-utils 2.3.3 → 2.4.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/dist/src/buffers.d.ts +1 -0
- package/dist/src/buffers.d.ts.map +1 -1
- package/dist/src/buffers.js +10 -1
- package/dist/src/buffers.js.map +1 -1
- package/package.json +2 -2
package/dist/src/buffers.d.ts
CHANGED
|
@@ -6,4 +6,5 @@ export declare function ensureBuffer(input: string | Buffer, encoding?: BufferEn
|
|
|
6
6
|
* Check if an input is an nodejs Buffer
|
|
7
7
|
*/
|
|
8
8
|
export declare function isBuffer(input: unknown): input is Buffer;
|
|
9
|
+
export declare function bufferToString(input: unknown, format?: BufferEncoding): string;
|
|
9
10
|
//# sourceMappingURL=buffers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffers.d.ts","sourceRoot":"","sources":["../../src/buffers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"buffers.d.ts","sourceRoot":"","sources":["../../src/buffers.ts"],"names":[],"mappings":"AAGA;;EAEE;AACF,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,GAAE,cAAuB,GAAG,MAAM,CAQ9F;AAED;;EAEE;AACF,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAGxD;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,GAAkB,cAAc,UAMpF"}
|
package/dist/src/buffers.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { isString } from './strings.js';
|
|
1
2
|
import { getTypeOf } from './deps.js';
|
|
2
3
|
/**
|
|
3
4
|
* Convert an input to a Buffer if possible
|
|
4
5
|
*/
|
|
5
6
|
export function ensureBuffer(input, encoding = 'utf8') {
|
|
6
|
-
if (
|
|
7
|
+
if (isString(input)) {
|
|
7
8
|
return Buffer.from(input, encoding);
|
|
8
9
|
}
|
|
9
10
|
if (isBuffer(input)) {
|
|
@@ -19,4 +20,12 @@ export function isBuffer(input) {
|
|
|
19
20
|
return false;
|
|
20
21
|
return Buffer.isBuffer(input);
|
|
21
22
|
}
|
|
23
|
+
export function bufferToString(input, format = 'base64url') {
|
|
24
|
+
if (isString(input))
|
|
25
|
+
return input;
|
|
26
|
+
if (isBuffer(input)) {
|
|
27
|
+
return input.toString(format);
|
|
28
|
+
}
|
|
29
|
+
throw new Error(`Invalid input given, expected string or buffer, got ${getTypeOf(input)}`);
|
|
30
|
+
}
|
|
22
31
|
//# sourceMappingURL=buffers.js.map
|
package/dist/src/buffers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffers.js","sourceRoot":"","sources":["../../src/buffers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC;;EAEE;AACF,MAAM,UAAU,YAAY,CAAC,KAAsB,EAAE,WAA2B,MAAM;IAClF,IAAI,
|
|
1
|
+
{"version":3,"file":"buffers.js","sourceRoot":"","sources":["../../src/buffers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC;;EAEE;AACF,MAAM,UAAU,YAAY,CAAC,KAAsB,EAAE,WAA2B,MAAM;IAClF,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAClB,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACxC,CAAC;IACD,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAClB,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,uDAAuD,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAC/F,CAAC;AAED;;EAEE;AACF,MAAM,UAAU,QAAQ,CAAC,KAAc;IACnC,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO,KAAK,CAAC;IAChD,OAAO,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAc,EAAE,SAAS,WAA6B;IACjF,IAAI,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAClC,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QAClB,OAAO,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,uDAAuD,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAC/F,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@terascope/core-utils",
|
|
3
3
|
"displayName": "Core Utils",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.4.0",
|
|
5
5
|
"description": "A collection of Teraslice Core Utilities",
|
|
6
6
|
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/core-utils#readme",
|
|
7
7
|
"bugs": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"shallow-clone": "~3.0.1",
|
|
35
35
|
"validator": "~13.15.26",
|
|
36
36
|
"zod": "~4.1.12",
|
|
37
|
-
"@terascope/types": "~2.
|
|
37
|
+
"@terascope/types": "~2.4.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@jest/globals": "^30.2.0",
|