@junobuild/utils 0.2.2 → 0.2.3
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/browser/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsonReplacer as n,jsonReviver as t}from"@dfinity/utils";var a=async r=>{let o=new Blob([JSON.stringify(r,n)],{type:"application/json; charset=utf-8"});return new Uint8Array(await o.arrayBuffer())},i=async r=>{let o=new Blob([r instanceof Uint8Array?r:new Uint8Array(r)],{type:"application/json; charset=utf-8"});return JSON.parse(await o.text(),t)};var
|
|
1
|
+
import{jsonReplacer as n,jsonReviver as t}from"@dfinity/utils";var a=async r=>{let o=new Blob([JSON.stringify(r,n)],{type:"application/json; charset=utf-8"});return new Uint8Array(await o.arrayBuffer())},i=async r=>{let o=new Blob([r instanceof Uint8Array?r:new Uint8Array(r)],{type:"application/json; charset=utf-8"});return JSON.parse(await o.text(),t)};var y=()=>typeof window<"u";export{i as fromArray,y as isBrowser,a as toArray};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/did.utils.ts", "../../src/utils/env.utils.ts"],
|
|
4
|
-
"sourcesContent": ["import {jsonReplacer, jsonReviver} from '@dfinity/utils';\n\n/**\n * Converts data to a Uint8Array for transmission or storage.\n * @template T\n * @param {T} data - The data to convert.\n * @returns {Promise<Uint8Array>} A promise that resolves to a Uint8Array representation of the data.\n */\nexport const toArray = async <T>(data: T): Promise<Uint8Array> => {\n const blob
|
|
5
|
-
"mappings": "AAAA,OAAQ,gBAAAA,EAAc,eAAAC,MAAkB,iBAQjC,IAAMC,EAAU,MAAUC,GAAiC,CAChE,IAAMC,
|
|
4
|
+
"sourcesContent": ["import {jsonReplacer, jsonReviver} from '@dfinity/utils';\n\n/**\n * Converts data to a Uint8Array for transmission or storage.\n * @template T\n * @param {T} data - The data to convert.\n * @returns {Promise<Uint8Array>} A promise that resolves to a Uint8Array representation of the data.\n */\nexport const toArray = async <T>(data: T): Promise<Uint8Array> => {\n const blob = new Blob([JSON.stringify(data, jsonReplacer)], {\n type: 'application/json; charset=utf-8'\n });\n return new Uint8Array(await blob.arrayBuffer());\n};\n\n/**\n * Converts a Uint8Array or number array back to the original data type.\n * @template T\n * @param {(Uint8Array | number[])} data - The array to convert.\n * @returns {Promise<T>} A promise that resolves to the original data.\n */\nexport const fromArray = async <T>(data: Uint8Array | number[]): Promise<T> => {\n const blob = new Blob(\n [data instanceof Uint8Array ? (data as Uint8Array<ArrayBuffer>) : new Uint8Array(data)],\n {\n type: 'application/json; charset=utf-8'\n }\n );\n return JSON.parse(await blob.text(), jsonReviver);\n};\n", "/**\n * Checks if the current environment is a browser.\n * @returns {boolean} True if the current environment is a browser, false otherwise.\n */\nexport const isBrowser = (): boolean => typeof window !== `undefined`;\n"],
|
|
5
|
+
"mappings": "AAAA,OAAQ,gBAAAA,EAAc,eAAAC,MAAkB,iBAQjC,IAAMC,EAAU,MAAUC,GAAiC,CAChE,IAAMC,EAAO,IAAI,KAAK,CAAC,KAAK,UAAUD,EAAMH,CAAY,CAAC,EAAG,CAC1D,KAAM,iCACR,CAAC,EACD,OAAO,IAAI,WAAW,MAAMI,EAAK,YAAY,CAAC,CAChD,EAQaC,EAAY,MAAUF,GAA4C,CAC7E,IAAMC,EAAO,IAAI,KACf,CAACD,aAAgB,WAAcA,EAAmC,IAAI,WAAWA,CAAI,CAAC,EACtF,CACE,KAAM,iCACR,CACF,EACA,OAAO,KAAK,MAAM,MAAMC,EAAK,KAAK,EAAGH,CAAW,CAClD,ECzBO,IAAMK,EAAY,IAAe,OAAO,OAAW",
|
|
6
6
|
"names": ["jsonReplacer", "jsonReviver", "toArray", "data", "blob", "fromArray", "isBrowser"]
|
|
7
7
|
}
|
package/dist/node/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as topLevelCreateRequire } from 'module';
|
|
2
2
|
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
-
import{jsonReplacer as n,jsonReviver as t}from"@dfinity/utils";var a=async r=>{let o=new Blob([JSON.stringify(r,n)],{type:"application/json; charset=utf-8"});return new Uint8Array(await o.arrayBuffer())},i=async r=>{let o=new Blob([r instanceof Uint8Array?r:new Uint8Array(r)],{type:"application/json; charset=utf-8"});return JSON.parse(await o.text(),t)};var
|
|
3
|
+
import{jsonReplacer as n,jsonReviver as t}from"@dfinity/utils";var a=async r=>{let o=new Blob([JSON.stringify(r,n)],{type:"application/json; charset=utf-8"});return new Uint8Array(await o.arrayBuffer())},i=async r=>{let o=new Blob([r instanceof Uint8Array?r:new Uint8Array(r)],{type:"application/json; charset=utf-8"});return JSON.parse(await o.text(),t)};var y=()=>typeof window<"u";export{i as fromArray,y as isBrowser,a as toArray};
|
|
4
4
|
//# sourceMappingURL=index.mjs.map
|
package/dist/node/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/did.utils.ts", "../../src/utils/env.utils.ts"],
|
|
4
|
-
"sourcesContent": ["import {jsonReplacer, jsonReviver} from '@dfinity/utils';\n\n/**\n * Converts data to a Uint8Array for transmission or storage.\n * @template T\n * @param {T} data - The data to convert.\n * @returns {Promise<Uint8Array>} A promise that resolves to a Uint8Array representation of the data.\n */\nexport const toArray = async <T>(data: T): Promise<Uint8Array> => {\n const blob
|
|
5
|
-
"mappings": ";;AAAA,OAAQ,gBAAAA,EAAc,eAAAC,MAAkB,iBAQjC,IAAMC,EAAU,MAAUC,GAAiC,CAChE,IAAMC,
|
|
4
|
+
"sourcesContent": ["import {jsonReplacer, jsonReviver} from '@dfinity/utils';\n\n/**\n * Converts data to a Uint8Array for transmission or storage.\n * @template T\n * @param {T} data - The data to convert.\n * @returns {Promise<Uint8Array>} A promise that resolves to a Uint8Array representation of the data.\n */\nexport const toArray = async <T>(data: T): Promise<Uint8Array> => {\n const blob = new Blob([JSON.stringify(data, jsonReplacer)], {\n type: 'application/json; charset=utf-8'\n });\n return new Uint8Array(await blob.arrayBuffer());\n};\n\n/**\n * Converts a Uint8Array or number array back to the original data type.\n * @template T\n * @param {(Uint8Array | number[])} data - The array to convert.\n * @returns {Promise<T>} A promise that resolves to the original data.\n */\nexport const fromArray = async <T>(data: Uint8Array | number[]): Promise<T> => {\n const blob = new Blob(\n [data instanceof Uint8Array ? (data as Uint8Array<ArrayBuffer>) : new Uint8Array(data)],\n {\n type: 'application/json; charset=utf-8'\n }\n );\n return JSON.parse(await blob.text(), jsonReviver);\n};\n", "/**\n * Checks if the current environment is a browser.\n * @returns {boolean} True if the current environment is a browser, false otherwise.\n */\nexport const isBrowser = (): boolean => typeof window !== `undefined`;\n"],
|
|
5
|
+
"mappings": ";;AAAA,OAAQ,gBAAAA,EAAc,eAAAC,MAAkB,iBAQjC,IAAMC,EAAU,MAAUC,GAAiC,CAChE,IAAMC,EAAO,IAAI,KAAK,CAAC,KAAK,UAAUD,EAAMH,CAAY,CAAC,EAAG,CAC1D,KAAM,iCACR,CAAC,EACD,OAAO,IAAI,WAAW,MAAMI,EAAK,YAAY,CAAC,CAChD,EAQaC,EAAY,MAAUF,GAA4C,CAC7E,IAAMC,EAAO,IAAI,KACf,CAACD,aAAgB,WAAcA,EAAmC,IAAI,WAAWA,CAAI,CAAC,EACtF,CACE,KAAM,iCACR,CACF,EACA,OAAO,KAAK,MAAM,MAAMC,EAAK,KAAK,EAAGH,CAAW,CAClD,ECzBO,IAAMK,EAAY,IAAe,OAAO,OAAW",
|
|
6
6
|
"names": ["jsonReplacer", "jsonReviver", "toArray", "data", "blob", "fromArray", "isBrowser"]
|
|
7
7
|
}
|