shelving 1.134.1 → 1.135.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/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "state-management",
12
12
  "query-builder"
13
13
  ],
14
- "version": "1.134.1",
14
+ "version": "1.135.0",
15
15
  "repository": "https://github.com/dhoulb/shelving",
16
16
  "author": "Dave Houlbrooke <dave@shax.com>",
17
17
  "license": "0BSD",
@@ -0,0 +1,8 @@
1
+ /** Encode a string to Base64 (with no `=` padding on the end). */
2
+ export declare function base64Encode(str: string): string;
3
+ /** Decode a string from Base64 (strips `=` padding on the end). */
4
+ export declare function base64Decode(b64: string): string;
5
+ /** Encode a string to URL-safe Base64 */
6
+ export declare function base64UrlEncode(str: string): string;
7
+ /** Decode a string from URL-safe Base64. */
8
+ export declare function base64UrlDecode(b64: string): string;
package/util/base64.js ADDED
@@ -0,0 +1,16 @@
1
+ /** Encode a string to Base64 (with no `=` padding on the end). */
2
+ export function base64Encode(str) {
3
+ return btoa(str).replace(/=+$/, "");
4
+ }
5
+ /** Decode a string from Base64 (strips `=` padding on the end). */
6
+ export function base64Decode(b64) {
7
+ return atob(b64.replace(/=+$/, ""));
8
+ }
9
+ /** Encode a string to URL-safe Base64 */
10
+ export function base64UrlEncode(str) {
11
+ return base64Encode(str).replace(/\+/g, "-").replace(/\//g, "_");
12
+ }
13
+ /** Decode a string from URL-safe Base64. */
14
+ export function base64UrlDecode(b64) {
15
+ return base64Decode(b64.replace(/-/g, "+").replace(/_/g, "/"));
16
+ }
package/util/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from "./array.js";
2
2
  export * from "./assert.js";
3
3
  export * from "./async.js";
4
+ export * from "./base64.js";
4
5
  export * from "./boolean.js";
5
6
  export * from "./callback.js";
6
7
  export * from "./class.js";
package/util/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from "./array.js";
2
2
  export * from "./assert.js";
3
3
  export * from "./async.js";
4
+ export * from "./base64.js";
4
5
  export * from "./boolean.js";
5
6
  export * from "./callback.js";
6
7
  export * from "./class.js";