@agnostack/verifyd 1.0.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/CHANGELOG.md +8 -0
- package/CODE_OF_CONDUCT.md +132 -0
- package/LICENSE +21 -0
- package/README.md +93 -0
- package/SECURITY.md +18 -0
- package/dist/lib/index.d.ts +4 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +20 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/types.d.ts +1 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +1 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/utils/errors.d.ts +6 -0
- package/dist/lib/utils/errors.d.ts.map +1 -0
- package/dist/lib/utils/errors.js +26 -0
- package/dist/lib/utils/errors.js.map +1 -0
- package/dist/lib/utils/index.d.ts +3 -0
- package/dist/lib/utils/index.d.ts.map +1 -0
- package/dist/lib/utils/index.js +19 -0
- package/dist/lib/utils/index.js.map +1 -0
- package/dist/lib/utils/rawbody.d.ts +2 -0
- package/dist/lib/utils/rawbody.d.ts.map +1 -0
- package/dist/lib/utils/rawbody.js +60 -0
- package/dist/lib/utils/rawbody.js.map +1 -0
- package/dist/lib/verification.d.ts +10 -0
- package/dist/lib/verification.d.ts.map +1 -0
- package/dist/lib/verification.js +84 -0
- package/dist/lib/verification.js.map +1 -0
- package/dist/react/hooks/index.d.ts +2 -0
- package/dist/react/hooks/index.d.ts.map +1 -0
- package/dist/react/hooks/index.js +18 -0
- package/dist/react/hooks/index.js.map +1 -0
- package/dist/react/hooks/useVerification.d.ts +8 -0
- package/dist/react/hooks/useVerification.d.ts.map +1 -0
- package/dist/react/hooks/useVerification.js +52 -0
- package/dist/react/hooks/useVerification.js.map +1 -0
- package/dist/react/index.d.ts +3 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +19 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/types.d.ts +1 -0
- package/dist/react/types.d.ts.map +1 -0
- package/dist/react/types.js +1 -0
- package/dist/react/types.js.map +1 -0
- package/dist/shared/WebCrypto.d.ts +55 -0
- package/dist/shared/WebCrypto.d.ts.map +1 -0
- package/dist/shared/WebCrypto.js +342 -0
- package/dist/shared/WebCrypto.js.map +1 -0
- package/dist/shared/datetime.d.ts +96 -0
- package/dist/shared/datetime.d.ts.map +1 -0
- package/dist/shared/datetime.js +295 -0
- package/dist/shared/datetime.js.map +1 -0
- package/dist/shared/display.d.ts +100 -0
- package/dist/shared/display.d.ts.map +1 -0
- package/dist/shared/display.js +481 -0
- package/dist/shared/display.js.map +1 -0
- package/dist/shared/index.d.ts +6 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/index.js +28 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/request.d.ts +16 -0
- package/dist/shared/request.d.ts.map +1 -0
- package/dist/shared/request.js +60 -0
- package/dist/shared/request.js.map +1 -0
- package/dist/shared/types.d.ts +1 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/shared/types.js +1 -0
- package/dist/shared/types.js.map +1 -0
- package/dist/shared/verification.d.ts +31 -0
- package/dist/shared/verification.d.ts.map +1 -0
- package/dist/shared/verification.js +91 -0
- package/dist/shared/verification.js.map +1 -0
- package/dist/umd/lib/index.js +2204 -0
- package/dist/umd/lib/index.js.map +1 -0
- package/dist/umd/lib/lib/index.d.ts +4 -0
- package/dist/umd/lib/lib/index.d.ts.map +1 -0
- package/dist/umd/lib/lib/types.d.ts +1 -0
- package/dist/umd/lib/lib/types.d.ts.map +1 -0
- package/dist/umd/lib/lib/utils/errors.d.ts +6 -0
- package/dist/umd/lib/lib/utils/errors.d.ts.map +1 -0
- package/dist/umd/lib/lib/utils/index.d.ts +3 -0
- package/dist/umd/lib/lib/utils/index.d.ts.map +1 -0
- package/dist/umd/lib/lib/utils/rawbody.d.ts +2 -0
- package/dist/umd/lib/lib/utils/rawbody.d.ts.map +1 -0
- package/dist/umd/lib/lib/verification.d.ts +10 -0
- package/dist/umd/lib/lib/verification.d.ts.map +1 -0
- package/dist/umd/lib/react/hooks/index.d.ts +2 -0
- package/dist/umd/lib/react/hooks/index.d.ts.map +1 -0
- package/dist/umd/lib/react/hooks/useVerification.d.ts +8 -0
- package/dist/umd/lib/react/hooks/useVerification.d.ts.map +1 -0
- package/dist/umd/lib/react/index.d.ts +3 -0
- package/dist/umd/lib/react/index.d.ts.map +1 -0
- package/dist/umd/lib/react/types.d.ts +1 -0
- package/dist/umd/lib/react/types.d.ts.map +1 -0
- package/dist/umd/lib/shared/WebCrypto.d.ts +55 -0
- package/dist/umd/lib/shared/WebCrypto.d.ts.map +1 -0
- package/dist/umd/lib/shared/datetime.d.ts +96 -0
- package/dist/umd/lib/shared/datetime.d.ts.map +1 -0
- package/dist/umd/lib/shared/display.d.ts +100 -0
- package/dist/umd/lib/shared/display.d.ts.map +1 -0
- package/dist/umd/lib/shared/index.d.ts +6 -0
- package/dist/umd/lib/shared/index.d.ts.map +1 -0
- package/dist/umd/lib/shared/request.d.ts +16 -0
- package/dist/umd/lib/shared/request.d.ts.map +1 -0
- package/dist/umd/lib/shared/types.d.ts +1 -0
- package/dist/umd/lib/shared/types.d.ts.map +1 -0
- package/dist/umd/lib/shared/verification.d.ts +31 -0
- package/dist/umd/lib/shared/verification.d.ts.map +1 -0
- package/node_modules/browser-monads-ts/LICENSE +21 -0
- package/node_modules/browser-monads-ts/README.md +46 -0
- package/node_modules/browser-monads-ts/dist/browser-monads-ts.cjs.js +2 -0
- package/node_modules/browser-monads-ts/dist/browser-monads-ts.cjs.js.map +1 -0
- package/node_modules/browser-monads-ts/dist/browser-monads-ts.es.js +12 -0
- package/node_modules/browser-monads-ts/dist/browser-monads-ts.es.js.map +1 -0
- package/node_modules/browser-monads-ts/dist/index.d.ts +5 -0
- package/node_modules/browser-monads-ts/dist/index.d.ts.map +1 -0
- package/node_modules/browser-monads-ts/package.json +79 -0
- package/node_modules/bytes/History.md +97 -0
- package/node_modules/bytes/LICENSE +23 -0
- package/node_modules/bytes/Readme.md +152 -0
- package/node_modules/bytes/index.js +170 -0
- package/node_modules/bytes/package.json +42 -0
- package/node_modules/depd/History.md +103 -0
- package/node_modules/depd/LICENSE +22 -0
- package/node_modules/depd/Readme.md +280 -0
- package/node_modules/depd/index.js +538 -0
- package/node_modules/depd/lib/browser/index.js +77 -0
- package/node_modules/depd/package.json +45 -0
- package/node_modules/http-errors/HISTORY.md +180 -0
- package/node_modules/http-errors/LICENSE +23 -0
- package/node_modules/http-errors/README.md +169 -0
- package/node_modules/http-errors/index.js +289 -0
- package/node_modules/http-errors/package.json +50 -0
- package/node_modules/iconv-lite/Changelog.md +162 -0
- package/node_modules/iconv-lite/LICENSE +21 -0
- package/node_modules/iconv-lite/README.md +156 -0
- package/node_modules/iconv-lite/encodings/dbcs-codec.js +555 -0
- package/node_modules/iconv-lite/encodings/dbcs-data.js +176 -0
- package/node_modules/iconv-lite/encodings/index.js +22 -0
- package/node_modules/iconv-lite/encodings/internal.js +188 -0
- package/node_modules/iconv-lite/encodings/sbcs-codec.js +72 -0
- package/node_modules/iconv-lite/encodings/sbcs-data-generated.js +451 -0
- package/node_modules/iconv-lite/encodings/sbcs-data.js +174 -0
- package/node_modules/iconv-lite/encodings/tables/big5-added.json +122 -0
- package/node_modules/iconv-lite/encodings/tables/cp936.json +264 -0
- package/node_modules/iconv-lite/encodings/tables/cp949.json +273 -0
- package/node_modules/iconv-lite/encodings/tables/cp950.json +177 -0
- package/node_modules/iconv-lite/encodings/tables/eucjp.json +182 -0
- package/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +1 -0
- package/node_modules/iconv-lite/encodings/tables/gbk-added.json +55 -0
- package/node_modules/iconv-lite/encodings/tables/shiftjis.json +125 -0
- package/node_modules/iconv-lite/encodings/utf16.js +177 -0
- package/node_modules/iconv-lite/encodings/utf7.js +290 -0
- package/node_modules/iconv-lite/lib/bom-handling.js +52 -0
- package/node_modules/iconv-lite/lib/extend-node.js +217 -0
- package/node_modules/iconv-lite/lib/index.d.ts +24 -0
- package/node_modules/iconv-lite/lib/index.js +153 -0
- package/node_modules/iconv-lite/lib/streams.js +121 -0
- package/node_modules/iconv-lite/package.json +46 -0
- package/node_modules/inherits/LICENSE +16 -0
- package/node_modules/inherits/README.md +42 -0
- package/node_modules/inherits/inherits.js +9 -0
- package/node_modules/inherits/inherits_browser.js +27 -0
- package/node_modules/inherits/package.json +29 -0
- package/node_modules/nothing-mock/LICENSE +21 -0
- package/node_modules/nothing-mock/README.md +266 -0
- package/node_modules/nothing-mock/dist/nothing-mock.es.js +2 -0
- package/node_modules/nothing-mock/dist/nothing-mock.es.js.map +1 -0
- package/node_modules/nothing-mock/dist/nothing-mock.js +2 -0
- package/node_modules/nothing-mock/dist/nothing-mock.js.map +1 -0
- package/node_modules/nothing-mock/dist/nothing-mock.modern.js +2 -0
- package/node_modules/nothing-mock/dist/nothing-mock.modern.js.map +1 -0
- package/node_modules/nothing-mock/dist/nothing-mock.umd.js +2 -0
- package/node_modules/nothing-mock/dist/nothing-mock.umd.js.map +1 -0
- package/node_modules/nothing-mock/index.d.ts +6 -0
- package/node_modules/nothing-mock/package.json +29 -0
- package/node_modules/nothing-mock/src/index.js +15 -0
- package/node_modules/raw-body/HISTORY.md +308 -0
- package/node_modules/raw-body/LICENSE +22 -0
- package/node_modules/raw-body/README.md +223 -0
- package/node_modules/raw-body/SECURITY.md +24 -0
- package/node_modules/raw-body/index.d.ts +87 -0
- package/node_modules/raw-body/index.js +336 -0
- package/node_modules/raw-body/package.json +49 -0
- package/node_modules/safer-buffer/LICENSE +21 -0
- package/node_modules/safer-buffer/Porting-Buffer.md +268 -0
- package/node_modules/safer-buffer/Readme.md +156 -0
- package/node_modules/safer-buffer/dangerous.js +58 -0
- package/node_modules/safer-buffer/package.json +34 -0
- package/node_modules/safer-buffer/safer.js +77 -0
- package/node_modules/safer-buffer/tests.js +406 -0
- package/node_modules/setprototypeof/LICENSE +13 -0
- package/node_modules/setprototypeof/README.md +31 -0
- package/node_modules/setprototypeof/index.d.ts +2 -0
- package/node_modules/setprototypeof/index.js +17 -0
- package/node_modules/setprototypeof/package.json +38 -0
- package/node_modules/setprototypeof/test/index.js +24 -0
- package/node_modules/statuses/HISTORY.md +82 -0
- package/node_modules/statuses/LICENSE +23 -0
- package/node_modules/statuses/README.md +136 -0
- package/node_modules/statuses/codes.json +65 -0
- package/node_modules/statuses/index.js +146 -0
- package/node_modules/statuses/package.json +49 -0
- package/node_modules/toidentifier/HISTORY.md +9 -0
- package/node_modules/toidentifier/LICENSE +21 -0
- package/node_modules/toidentifier/README.md +61 -0
- package/node_modules/toidentifier/index.js +32 -0
- package/node_modules/toidentifier/package.json +38 -0
- package/node_modules/unpipe/HISTORY.md +4 -0
- package/node_modules/unpipe/LICENSE +22 -0
- package/node_modules/unpipe/README.md +43 -0
- package/node_modules/unpipe/index.js +69 -0
- package/node_modules/unpipe/package.json +27 -0
- package/package.json +127 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export function normalizeShopifyId(shopifyData: any): {
|
|
2
|
+
gid?: string | undefined;
|
|
3
|
+
entity_type?: string | undefined;
|
|
4
|
+
entity_id?: string | undefined;
|
|
5
|
+
id?: string | undefined;
|
|
6
|
+
};
|
|
7
|
+
export function random(max?: number, min?: number): number;
|
|
8
|
+
export function nextRandom(max?: number, min?: number): any;
|
|
9
|
+
export function arrayRandom(_values: any, _max?: number): any[];
|
|
10
|
+
export function arrayRandomItem(_values: any): any;
|
|
11
|
+
export function isArray(value: any): boolean;
|
|
12
|
+
export function isSet(value: any): boolean;
|
|
13
|
+
export function isType(value: any, type: any): boolean;
|
|
14
|
+
export function isTypeEnhanced(value: any, type: any): boolean;
|
|
15
|
+
export function safeTrim(value: any): any;
|
|
16
|
+
export function safeParse(value: any, trim: any): any;
|
|
17
|
+
export function ensureString(string: any): string;
|
|
18
|
+
export function ensureStringOnly(string: any): string;
|
|
19
|
+
export function ensureStringAscii(string: any): string;
|
|
20
|
+
export function ensureStringClean(string: any): string;
|
|
21
|
+
export function ensureAlphaNumeric(string: any): string;
|
|
22
|
+
export function isNumericOnly(value: any): boolean;
|
|
23
|
+
export function isNumericNegatable(value: any): boolean;
|
|
24
|
+
export function ensureNumeric(string: any): number;
|
|
25
|
+
export function ensureNumericOnly(string: any): number;
|
|
26
|
+
export function ensureNumericNegatable(string: any): number;
|
|
27
|
+
export function ensureNumericConstrained(value: any, { min: _min, max: _max }?: {
|
|
28
|
+
min?: number | undefined;
|
|
29
|
+
max?: number | undefined;
|
|
30
|
+
}): number;
|
|
31
|
+
export function ensureArray(array?: any[]): any[];
|
|
32
|
+
export function ensureArraySet(arrayOrSet: any): any[];
|
|
33
|
+
export function arrayEmpty(array: any, disableEmptyString?: boolean): boolean;
|
|
34
|
+
export function arrayNotEmpty(array: any, disableEmptyString?: boolean): boolean;
|
|
35
|
+
export function findLastMatch(array: any, filterCallback?: (value: any) => any): any;
|
|
36
|
+
export function ensureObject(object: any): any;
|
|
37
|
+
export function objectEmpty(object: any): boolean;
|
|
38
|
+
export function objectNotEmpty(object: any): boolean;
|
|
39
|
+
export function nullable(object: any): any;
|
|
40
|
+
export function objectContainsAnyValue(object: any): boolean;
|
|
41
|
+
export function cleanObject(object: any, allowEmptyLeafs: any, isEmptyCallback: any): any;
|
|
42
|
+
export function stringNotEmptyOnly(stringable: any): boolean;
|
|
43
|
+
export function stringEmptyOnly(stringable: any): boolean;
|
|
44
|
+
export function stringNotEmpty(stringable: any): boolean;
|
|
45
|
+
export function stringEmpty(stringable: any): boolean;
|
|
46
|
+
export function compareNumber(number1?: number, number2?: number): number;
|
|
47
|
+
export function compareString(string1: any, string2: any): number;
|
|
48
|
+
export function compareEntryKeys([string1]: [any], [string2]: [any]): number;
|
|
49
|
+
export function objectToSortedString(object: any, separator?: string): string;
|
|
50
|
+
export function isHTML(string: any): any;
|
|
51
|
+
export function freeze(logMessage: any, object: any, type?: string): void;
|
|
52
|
+
export function replaceSpaces(string: any, replacement?: string): any;
|
|
53
|
+
export function zencase(string: any, replacement?: string): any;
|
|
54
|
+
export function dashcase(string: any): any;
|
|
55
|
+
export function undashcase(string: any, replacement?: string): string;
|
|
56
|
+
export function snakecase(string: any): any;
|
|
57
|
+
export function unsnakecase(string: any, replacement?: string): string;
|
|
58
|
+
export function uppercase(string: any): string;
|
|
59
|
+
export function lowercase(string: any, defaultValue?: string): string;
|
|
60
|
+
export function slugify(string: any): string;
|
|
61
|
+
export function capitalize(string: any): string;
|
|
62
|
+
export function camelCase(string: any): string;
|
|
63
|
+
export function titleCase(string: any, _overrides: any): string;
|
|
64
|
+
export function removeLeadingSlash(string: any): string;
|
|
65
|
+
export function removeLeadingTrailingQuotes(string: any): string;
|
|
66
|
+
export function removeTrailingSlash(string: any): string;
|
|
67
|
+
export function removeLeadingTrailingSlash(string: any): string;
|
|
68
|
+
export function ensureLeadingSlash(string: any): string;
|
|
69
|
+
export function ensureTrailingSlash(string: any): string;
|
|
70
|
+
export function ensureExtension(string: any, extension: any): any;
|
|
71
|
+
export function wrappedEncode(basePath: any, _wrappingPath: any): string;
|
|
72
|
+
export function splitCommas(value: any): any[];
|
|
73
|
+
export function combineCommas(values: any): any[];
|
|
74
|
+
export function normalizeArray(input: any, separator?: string): any;
|
|
75
|
+
export function arrayToObject(arrayable: any, key: any): any;
|
|
76
|
+
export function isTrue(value: any, falsy: any): boolean;
|
|
77
|
+
export function parseKeywords(keywordGroup: any, previous: any): string;
|
|
78
|
+
export function parseKeywordGroups(keywordGroups: any): string;
|
|
79
|
+
export function parseProjectName(_name: any): {
|
|
80
|
+
name: string;
|
|
81
|
+
parts: string[];
|
|
82
|
+
organization: string;
|
|
83
|
+
projectName: string;
|
|
84
|
+
};
|
|
85
|
+
export function parseProject(packageInfo: any): (string | {
|
|
86
|
+
keywords: any;
|
|
87
|
+
appOwner: any;
|
|
88
|
+
appName: any;
|
|
89
|
+
siteName: any;
|
|
90
|
+
shortName: any;
|
|
91
|
+
companyName: string;
|
|
92
|
+
projectName: string;
|
|
93
|
+
})[];
|
|
94
|
+
export function querystringToObject(queryString: any): {
|
|
95
|
+
[k: string]: string;
|
|
96
|
+
};
|
|
97
|
+
export function arrayIncludesAll(_values: any, comparison: any): boolean;
|
|
98
|
+
export function arraysMatch(array1: any, array2: any): boolean;
|
|
99
|
+
export function appendQuery(_basePath: any, queryString: any): string;
|
|
100
|
+
//# sourceMappingURL=display.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"display.d.ts","sourceRoot":"","sources":["../../src/shared/display.js"],"names":[],"mappings":"AAIO;;;;;EAmCN;AAEM,2DAGN;AAEM,4DAeN;AAEM,gEAmBN;AAEM,mDAEN;AAEM,6CAGN;AAEM,2CAGN;AAEM,uDAGN;AAEM,+DAwBN;AAEM,0CAON;AAEM,sDAeN;AAEM,kDAEN;AAGM,sDAGN;AAEM,uDAGN;AAEM,uDAGN;AAEM,wDAGN;AAEM,mDAIN;AAEM,wDAIN;AAGM,mDAEN;AAEM,uDAEN;AAGM,4DAEN;AAEM;;;WAQN;AAEM,kDAGN;AAEM,uDAEN;AAEM,8EAGN;AAEM,iFAGN;AAEM,qFAEN;AAEM,+CAEN;AAGM,kDAEN;AAEM,qDAEN;AAEM,2CAIN;AAEM,6DAEN;AAOM,0FAqBN;AAMM,6DAGN;AAEM,0DAEN;AAEM,yDAGN;AAEM,sDAEN;AAOM,0EAEN;AAEM,kEAUN;AAEM,6EAEN;AAEM,8EAKN;AAEM,yCAEN;AAEM,0EAEN;AAEM,sEAIN;AAgBM,gEAQN;AAEM,2CAEN;AAEM,sEAEN;AAEM,4CAEN;AAEM,uEAEN;AAEM,+CAEN;AAEM,sEAIN;AAEM,6CAEN;AAEM,gDAGN;AAEM,+CASN;AAEM,gEA6DN;AAEM,wDAEN;AAEM,iEAEN;AAGM,yDAEN;AAEM,gEAEN;AAEM,wDAEN;AAEM,yDAEN;AAEM,kEAQN;AAEM,yEAON;AAEM,+CAWN;AAEM,kDAUN;AAEM,oEAON;AAEM,6DAKN;AAEM,wDAGN;AAGM,wEASN;AAEM,+DAcN;AAEM;;;;;EAWN;AAEM;;;;;;;;KAkBN;AAMM;;EAON;AAEM,yEAKN;AAEM,+DAEN;AAEM,sEAMN"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AACA,cAAc,YAAY,CAAA;AAC1B,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const HEADER_CONTENT_TYPE: "Content-Type";
|
|
2
|
+
export namespace CONTENT_TYPES {
|
|
3
|
+
const APPLICATION_JSON: string;
|
|
4
|
+
}
|
|
5
|
+
export function getRequestMethod(body: any, _method: any): string;
|
|
6
|
+
export function prepareRequestOptions({ method: _method, body: _body, headers: _header, ...requestOptions }?: {
|
|
7
|
+
method: any;
|
|
8
|
+
body: any;
|
|
9
|
+
headers: any;
|
|
10
|
+
}): any;
|
|
11
|
+
export function normalizeURIParts(uri: any): {
|
|
12
|
+
pathname: string;
|
|
13
|
+
search: string;
|
|
14
|
+
origin?: string | undefined;
|
|
15
|
+
} | undefined;
|
|
16
|
+
//# sourceMappingURL=request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/shared/request.js"],"names":[],"mappings":"AAUA,iDAAiD;;;;AAK1C,kEAIN;AAEM;;;;QAmBN;AAgBM;;;;cAeN"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/shared/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export function getKeysData(publicKey: any, { crypto: _crypto, util: _util }?: {
|
|
2
|
+
crypto: any;
|
|
3
|
+
util: any;
|
|
4
|
+
}): Promise<{
|
|
5
|
+
publicKey: any;
|
|
6
|
+
ephemeral: {};
|
|
7
|
+
verification: {
|
|
8
|
+
derivedSecretKey?: undefined;
|
|
9
|
+
derivedHMACKey?: undefined;
|
|
10
|
+
} | {
|
|
11
|
+
derivedSecretKey: any;
|
|
12
|
+
derivedHMACKey: any;
|
|
13
|
+
};
|
|
14
|
+
}>;
|
|
15
|
+
export function prepareVerificationRequest({ keysData: _keysData, disableRecryption: _disableRecryption, crypto: _crypto, util: _util }?: {
|
|
16
|
+
keysData: any;
|
|
17
|
+
disableRecryption: any;
|
|
18
|
+
crypto: any;
|
|
19
|
+
util: any;
|
|
20
|
+
}): (requestPath: any, { method: rawMethod, body: rawBody, headers: rawHeaders, ...requestOptions }?: {
|
|
21
|
+
method: any;
|
|
22
|
+
body: any;
|
|
23
|
+
headers: any;
|
|
24
|
+
}) => Promise<any[] | undefined>;
|
|
25
|
+
export function processVerificationResponse({ keysData, disableRecryption: _disableRecryption, crypto: _crypto, util: _util }?: {
|
|
26
|
+
keysData: any;
|
|
27
|
+
disableRecryption: any;
|
|
28
|
+
crypto: any;
|
|
29
|
+
util: any;
|
|
30
|
+
}): (encryptedResponse: any, _derivedSecretKey: any) => Promise<any>;
|
|
31
|
+
//# sourceMappingURL=verification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verification.d.ts","sourceRoot":"","sources":["../../src/shared/verification.js"],"names":[],"mappings":"AAcO;;;;;;;;;;;;;GAiBN;AAGM;;;;;;;;;iCAkEN;AAEM;;;;;qEAaN"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Daniel Esteves
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Browser Monads TS
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<a href="https://www.npmjs.org/package/browser-monads-ts">
|
|
5
|
+
<img src="https://img.shields.io/npm/v/browser-monads-ts/latest.svg" alt="NPM Version" />
|
|
6
|
+
</a>
|
|
7
|
+
<a href="https://www.npmjs.org/package/browser-monads-ts">
|
|
8
|
+
<img src="https://img.shields.io/npm/dm/browser-monads-ts.svg" alt="Monthly download on NPM" />
|
|
9
|
+
</a>
|
|
10
|
+
<a href="https://github.com/danestves/browser-monads-ts/actions">
|
|
11
|
+
<img src="https://github.com/danestves/browser-monads-ts/workflows/CI/badge.svg" alt="Workflow of main.yml action" />
|
|
12
|
+
</a>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
> This package is inspired by [browser-monads](https://github.com/Jense5/browser-monads) currently without support from the author.
|
|
16
|
+
|
|
17
|
+
Provide interfaces for the `window`, `document` and `navigator` variables of a webpage.
|
|
18
|
+
|
|
19
|
+
## What is a monad?
|
|
20
|
+
|
|
21
|
+
> In functional programming, a monad is an abstraction that allows structuring programs generically. Supporting languages may use monads to abstract away boilerplate code needed by the program logic.
|
|
22
|
+
>
|
|
23
|
+
> -Wikipedia - [Monad (functional programming)](<https://en.wikipedia.org/wiki/Monad_(functional_programming)>)
|
|
24
|
+
|
|
25
|
+
You don't really have to know what a monad is since the variables provided by this library aren't _really_ monads. Let's take a look at the `window` variable to get a basic understanding. The main purpose of this variable is that it _may be a window_ or it _may be nothing_. You don't know what it is and you shouldn't really care. In case it is a window, you can use it as you're used to. In case it is not a window, you can still use the same functions on the instance. The caring about the existence of the variable is already taken care of.
|
|
26
|
+
|
|
27
|
+
This same concept is applicable to the `document` variable too. You can use the `exists` function in order to check if the variable exists or you are operating on an instance that contains _nothing_.
|
|
28
|
+
|
|
29
|
+
## Why use monads?
|
|
30
|
+
|
|
31
|
+
This library makes it possible to use these variables without checks with [Gatsby](https://www.gatsbyjs.org) and [NextJS](https://nextjs.org/). This way of programming splits the defensive part from your own code, since you don't have to care anymore about the environment in which you are running. This makes it especially useful with server-side rendering. More info about the `nothing`-type can be found [here](https://github.com/slmgc/Nothing).
|
|
32
|
+
|
|
33
|
+
## Example
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
import { window, document, exists } from 'browser-monads';
|
|
37
|
+
|
|
38
|
+
// inside browser ? window.location.href : ''
|
|
39
|
+
window.location.href;
|
|
40
|
+
|
|
41
|
+
// inside browser ? document.getElementById("myId") : ''
|
|
42
|
+
document.getElementById('myId');
|
|
43
|
+
|
|
44
|
+
// inside browser ? true : false
|
|
45
|
+
exists(window);
|
|
46
|
+
```
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var n,t=((n=function(){return t}).toString=n.toLocaleString=n[Symbol.toPrimitive]=function(){return""},n.valueOf=function(){return!1},new Proxy(Object.freeze(n),{get:function(e,o){return e.hasOwnProperty(o)?e[o]:t}})),l=function(e){return e===t};let r=global.window,i=global.document,u=global.navigator,a=typeof i<"u"?i:t,d=e=>!l(e),f=typeof u<"u"?u:t,c=typeof r<"u"?r:t;exports.document=a;exports.exists=d;exports.navigator=f;exports.window=c;
|
|
2
|
+
//# sourceMappingURL=browser-monads-ts.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-monads-ts.cjs.js","sources":["../node_modules/nothing-mock/dist/nothing-mock.es.js","../src/index.ts"],"sourcesContent":["var n,r=((n=function(){return r}).toString=n.toLocaleString=n[Symbol.toPrimitive]=function(){return\"\"},n.valueOf=function(){return!1},new Proxy(Object.freeze(n),{get:function(n,t){return n.hasOwnProperty(t)?n[t]:r}})),t=function(n){return!(!n||!n.valueOf())},u=function(n){return n===r},e=function(n){return!(n===r||null==n)},o=function(n){return JSON.stringify(n,function(n,t){return t===r?null:t})},i=function(n){return JSON.parse(n,function(n,t){return null===t?r:t})};export{r as Nothing,i as deserialize,u as isNothing,e as isSomething,o as serialize,t as toBool};\n//# sourceMappingURL=nothing-mock.es.js.map\n","// Dependencies\nimport { Nothing, isNothing } from 'nothing-mock';\n\nlet win = global.window;\nlet doc = global.document;\nlet nav = global.navigator;\n\nexport let document: Document = typeof doc !== 'undefined' ? doc : Nothing;\nexport let exists = (variable: any) => !isNothing(variable);\nexport let navigator: Navigator = typeof nav !== 'undefined' ? nav : Nothing;\nexport let window: Window = typeof win !== 'undefined' ? win : Nothing;\n"],"names":["Nothing","isNothing"],"mappings":"4GAAG,GAAC,GAAE,EAAI,IAAE,UAAU,CAAC,MAAO,EAAC,GAAG,SAAS,EAAE,eAAe,EAAE,OAAO,aAAa,UAAU,CAAC,MAAM,EAAE,EAAE,EAAE,QAAQ,UAAU,CAAC,MAAM,EAAE,EAAE,GAAI,OAAM,OAAO,OAAO,CAAC,EAAE,CAAC,IAAI,SAAS,EAAE,EAAE,CAAC,MAAO,GAAE,eAAe,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,GAA4C,EAAE,SAAS,EAAE,CAAC,MAAO,KAAI,CAAC,ECG7R,GAAI,GAAM,OAAO,OACb,EAAM,OAAO,SACb,EAAM,OAAO,UAEN,EAAqB,MAAO,GAAQ,IAAc,EAAMA,EACxD,EAAS,AAAC,GAAkB,CAACC,EAAU,CAAQ,EAC/C,EAAuB,MAAO,GAAQ,IAAc,EAAMD,EAC1D,EAAiB,MAAO,GAAQ,IAAc,EAAMA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var n,r=((n=function(){return r}).toString=n.toLocaleString=n[Symbol.toPrimitive]=function(){return ""},n.valueOf=function(){return !1},new Proxy(Object.freeze(n),{get:function(n,t){return n.hasOwnProperty(t)?n[t]:r}})),u=function(n){return n===r};
|
|
2
|
+
|
|
3
|
+
let win = global.window;
|
|
4
|
+
let doc = global.document;
|
|
5
|
+
let nav = global.navigator;
|
|
6
|
+
let document = typeof doc !== "undefined" ? doc : r;
|
|
7
|
+
let exists = (variable) => !u(variable);
|
|
8
|
+
let navigator = typeof nav !== "undefined" ? nav : r;
|
|
9
|
+
let window = typeof win !== "undefined" ? win : r;
|
|
10
|
+
|
|
11
|
+
export { document, exists, navigator, window };
|
|
12
|
+
//# sourceMappingURL=browser-monads-ts.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser-monads-ts.es.js","sources":["../node_modules/nothing-mock/dist/nothing-mock.es.js","../src/index.ts"],"sourcesContent":["var n,r=((n=function(){return r}).toString=n.toLocaleString=n[Symbol.toPrimitive]=function(){return\"\"},n.valueOf=function(){return!1},new Proxy(Object.freeze(n),{get:function(n,t){return n.hasOwnProperty(t)?n[t]:r}})),t=function(n){return!(!n||!n.valueOf())},u=function(n){return n===r},e=function(n){return!(n===r||null==n)},o=function(n){return JSON.stringify(n,function(n,t){return t===r?null:t})},i=function(n){return JSON.parse(n,function(n,t){return null===t?r:t})};export{r as Nothing,i as deserialize,u as isNothing,e as isSomething,o as serialize,t as toBool};\n//# sourceMappingURL=nothing-mock.es.js.map\n","// Dependencies\nimport { Nothing, isNothing } from 'nothing-mock';\n\nlet win = global.window;\nlet doc = global.document;\nlet nav = global.navigator;\n\nexport let document: Document = typeof doc !== 'undefined' ? doc : Nothing;\nexport let exists = (variable: any) => !isNothing(variable);\nexport let navigator: Navigator = typeof nav !== 'undefined' ? nav : Nothing;\nexport let window: Window = typeof win !== 'undefined' ? win : Nothing;\n"],"names":["Nothing","isNothing"],"mappings":"AAAG,IAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,UAAU,CAAC,OAAM,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,OAAM,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAA0C,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;;ACG9R,IAAI,MAAM,MAAO,CAAA,MAAA,CAAA;AACjB,IAAI,MAAM,MAAO,CAAA,QAAA,CAAA;AACjB,IAAI,MAAM,MAAO,CAAA,SAAA,CAAA;AAEV,IAAI,QAAqB,GAAA,OAAO,GAAQ,KAAA,WAAA,GAAc,GAAM,GAAAA,EAAA;AAC5D,IAAI,MAAS,GAAA,CAAC,QAAkB,KAAA,CAACC,EAAU,QAAQ,EAAA;AACnD,IAAI,SAAuB,GAAA,OAAO,GAAQ,KAAA,WAAA,GAAc,GAAM,GAAAD,EAAA;AAC9D,IAAI,MAAiB,GAAA,OAAO,GAAQ,KAAA,WAAA,GAAc,GAAM,GAAAA;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,eAAO,IAAI,QAAQ,EAAE,QAAqD,CAAC;AAC3E,eAAO,IAAI,MAAM,aAAc,GAAG,YAAyB,CAAC;AAC5D,eAAO,IAAI,SAAS,EAAE,SAAsD,CAAC;AAC7E,eAAO,IAAI,MAAM,EAAE,MAAmD,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "browser-monads-ts",
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"description": "Provide interfaces for the window, document and navigator variables of a webpage.",
|
|
5
|
+
"homepage": "https://github.com/danestves/browser-monads-ts#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/danestves/browser-monads-ts/issues",
|
|
8
|
+
"email": "estevesd8@gmail.com"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/danestves/browser-monads-ts.git"
|
|
13
|
+
},
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"author": "Daniel Esteves",
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"require": "./dist/browser-monads-ts.cjs.js",
|
|
20
|
+
"import": "./dist/browser-monads-ts.es.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"main": "dist/browser-monads-ts.cjs.js",
|
|
24
|
+
"module": "dist/browser-monads-ts.es.js",
|
|
25
|
+
"types": "dist/index.d.ts",
|
|
26
|
+
"typings": "dist/index.d.ts",
|
|
27
|
+
"directories": {
|
|
28
|
+
"src": "src"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist"
|
|
32
|
+
],
|
|
33
|
+
"scripts": {
|
|
34
|
+
"prebuild": "npm run clean",
|
|
35
|
+
"build": "run-p build:*",
|
|
36
|
+
"build:scripts": "vite build",
|
|
37
|
+
"build:types": "tsc --emitDeclarationOnly && tsc-alias",
|
|
38
|
+
"clean": "rimraf dist",
|
|
39
|
+
"dev": "vite",
|
|
40
|
+
"preview": "vite preview",
|
|
41
|
+
"prepublish": "npm run build",
|
|
42
|
+
"size": "size-limit"
|
|
43
|
+
},
|
|
44
|
+
"prettier": {
|
|
45
|
+
"printWidth": 80,
|
|
46
|
+
"semi": true,
|
|
47
|
+
"singleQuote": true,
|
|
48
|
+
"trailingComma": "es5"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"nothing-mock": "^1.0.4"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@esbuild-plugins/node-globals-polyfill": "^0.1.1",
|
|
55
|
+
"@size-limit/preset-small-lib": "^7.0.8",
|
|
56
|
+
"@types/node": "^17.0.21",
|
|
57
|
+
"npm-run-all": "^4.1.5",
|
|
58
|
+
"rimraf": "^3.0.2",
|
|
59
|
+
"rollup-plugin-node-polyfills": "^0.2.1",
|
|
60
|
+
"size-limit": "^7.0.8",
|
|
61
|
+
"tsc-alias": "^1.6.4",
|
|
62
|
+
"typescript": "^4.6.2",
|
|
63
|
+
"vite": "^2.8.6",
|
|
64
|
+
"vite-tsconfig-paths": "^3.4.1"
|
|
65
|
+
},
|
|
66
|
+
"engines": {
|
|
67
|
+
"node": ">=10"
|
|
68
|
+
},
|
|
69
|
+
"size-limit": [
|
|
70
|
+
{
|
|
71
|
+
"path": "dist/browser-monads-ts.cjs.js",
|
|
72
|
+
"limit": "10 KB"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"path": "dist/browser-monads-ts.es.js",
|
|
76
|
+
"limit": "10 KB"
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
3.1.2 / 2022-01-27
|
|
2
|
+
==================
|
|
3
|
+
|
|
4
|
+
* Fix return value for un-parsable strings
|
|
5
|
+
|
|
6
|
+
3.1.1 / 2021-11-15
|
|
7
|
+
==================
|
|
8
|
+
|
|
9
|
+
* Fix "thousandsSeparator" incorrecting formatting fractional part
|
|
10
|
+
|
|
11
|
+
3.1.0 / 2019-01-22
|
|
12
|
+
==================
|
|
13
|
+
|
|
14
|
+
* Add petabyte (`pb`) support
|
|
15
|
+
|
|
16
|
+
3.0.0 / 2017-08-31
|
|
17
|
+
==================
|
|
18
|
+
|
|
19
|
+
* Change "kB" to "KB" in format output
|
|
20
|
+
* Remove support for Node.js 0.6
|
|
21
|
+
* Remove support for ComponentJS
|
|
22
|
+
|
|
23
|
+
2.5.0 / 2017-03-24
|
|
24
|
+
==================
|
|
25
|
+
|
|
26
|
+
* Add option "unit"
|
|
27
|
+
|
|
28
|
+
2.4.0 / 2016-06-01
|
|
29
|
+
==================
|
|
30
|
+
|
|
31
|
+
* Add option "unitSeparator"
|
|
32
|
+
|
|
33
|
+
2.3.0 / 2016-02-15
|
|
34
|
+
==================
|
|
35
|
+
|
|
36
|
+
* Drop partial bytes on all parsed units
|
|
37
|
+
* Fix non-finite numbers to `.format` to return `null`
|
|
38
|
+
* Fix parsing byte string that looks like hex
|
|
39
|
+
* perf: hoist regular expressions
|
|
40
|
+
|
|
41
|
+
2.2.0 / 2015-11-13
|
|
42
|
+
==================
|
|
43
|
+
|
|
44
|
+
* add option "decimalPlaces"
|
|
45
|
+
* add option "fixedDecimals"
|
|
46
|
+
|
|
47
|
+
2.1.0 / 2015-05-21
|
|
48
|
+
==================
|
|
49
|
+
|
|
50
|
+
* add `.format` export
|
|
51
|
+
* add `.parse` export
|
|
52
|
+
|
|
53
|
+
2.0.2 / 2015-05-20
|
|
54
|
+
==================
|
|
55
|
+
|
|
56
|
+
* remove map recreation
|
|
57
|
+
* remove unnecessary object construction
|
|
58
|
+
|
|
59
|
+
2.0.1 / 2015-05-07
|
|
60
|
+
==================
|
|
61
|
+
|
|
62
|
+
* fix browserify require
|
|
63
|
+
* remove node.extend dependency
|
|
64
|
+
|
|
65
|
+
2.0.0 / 2015-04-12
|
|
66
|
+
==================
|
|
67
|
+
|
|
68
|
+
* add option "case"
|
|
69
|
+
* add option "thousandsSeparator"
|
|
70
|
+
* return "null" on invalid parse input
|
|
71
|
+
* support proper round-trip: bytes(bytes(num)) === num
|
|
72
|
+
* units no longer case sensitive when parsing
|
|
73
|
+
|
|
74
|
+
1.0.0 / 2014-05-05
|
|
75
|
+
==================
|
|
76
|
+
|
|
77
|
+
* add negative support. fixes #6
|
|
78
|
+
|
|
79
|
+
0.3.0 / 2014-03-19
|
|
80
|
+
==================
|
|
81
|
+
|
|
82
|
+
* added terabyte support
|
|
83
|
+
|
|
84
|
+
0.2.1 / 2013-04-01
|
|
85
|
+
==================
|
|
86
|
+
|
|
87
|
+
* add .component
|
|
88
|
+
|
|
89
|
+
0.2.0 / 2012-10-28
|
|
90
|
+
==================
|
|
91
|
+
|
|
92
|
+
* bytes(200).should.eql('200b')
|
|
93
|
+
|
|
94
|
+
0.1.0 / 2012-07-04
|
|
95
|
+
==================
|
|
96
|
+
|
|
97
|
+
* add bytes to string conversion [yields]
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
(The MIT License)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2012-2014 TJ Holowaychuk <tj@vision-media.ca>
|
|
4
|
+
Copyright (c) 2015 Jed Watson <jed.watson@me.com>
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
7
|
+
a copy of this software and associated documentation files (the
|
|
8
|
+
'Software'), to deal in the Software without restriction, including
|
|
9
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
10
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
12
|
+
the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be
|
|
15
|
+
included in all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
20
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
21
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
22
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
23
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# Bytes utility
|
|
2
|
+
|
|
3
|
+
[![NPM Version][npm-image]][npm-url]
|
|
4
|
+
[![NPM Downloads][downloads-image]][downloads-url]
|
|
5
|
+
[![Build Status][ci-image]][ci-url]
|
|
6
|
+
[![Test Coverage][coveralls-image]][coveralls-url]
|
|
7
|
+
|
|
8
|
+
Utility to parse a string bytes (ex: `1TB`) to bytes (`1099511627776`) and vice-versa.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
This is a [Node.js](https://nodejs.org/en/) module available through the
|
|
13
|
+
[npm registry](https://www.npmjs.com/). Installation is done using the
|
|
14
|
+
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
$ npm install bytes
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
var bytes = require('bytes');
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
#### bytes(number|string value, [options]): number|string|null
|
|
27
|
+
|
|
28
|
+
Default export function. Delegates to either `bytes.format` or `bytes.parse` based on the type of `value`.
|
|
29
|
+
|
|
30
|
+
**Arguments**
|
|
31
|
+
|
|
32
|
+
| Name | Type | Description |
|
|
33
|
+
|---------|----------|--------------------|
|
|
34
|
+
| value | `number`|`string` | Number value to format or string value to parse |
|
|
35
|
+
| options | `Object` | Conversion options for `format` |
|
|
36
|
+
|
|
37
|
+
**Returns**
|
|
38
|
+
|
|
39
|
+
| Name | Type | Description |
|
|
40
|
+
|---------|------------------|-------------------------------------------------|
|
|
41
|
+
| results | `string`|`number`|`null` | Return null upon error. Numeric value in bytes, or string value otherwise. |
|
|
42
|
+
|
|
43
|
+
**Example**
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
bytes(1024);
|
|
47
|
+
// output: '1KB'
|
|
48
|
+
|
|
49
|
+
bytes('1KB');
|
|
50
|
+
// output: 1024
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
#### bytes.format(number value, [options]): string|null
|
|
54
|
+
|
|
55
|
+
Format the given value in bytes into a string. If the value is negative, it is kept as such. If it is a float, it is
|
|
56
|
+
rounded.
|
|
57
|
+
|
|
58
|
+
**Arguments**
|
|
59
|
+
|
|
60
|
+
| Name | Type | Description |
|
|
61
|
+
|---------|----------|--------------------|
|
|
62
|
+
| value | `number` | Value in bytes |
|
|
63
|
+
| options | `Object` | Conversion options |
|
|
64
|
+
|
|
65
|
+
**Options**
|
|
66
|
+
|
|
67
|
+
| Property | Type | Description |
|
|
68
|
+
|-------------------|--------|-----------------------------------------------------------------------------------------|
|
|
69
|
+
| decimalPlaces | `number`|`null` | Maximum number of decimal places to include in output. Default value to `2`. |
|
|
70
|
+
| fixedDecimals | `boolean`|`null` | Whether to always display the maximum number of decimal places. Default value to `false` |
|
|
71
|
+
| thousandsSeparator | `string`|`null` | Example of values: `' '`, `','` and `'.'`... Default value to `''`. |
|
|
72
|
+
| unit | `string`|`null` | The unit in which the result will be returned (B/KB/MB/GB/TB). Default value to `''` (which means auto detect). |
|
|
73
|
+
| unitSeparator | `string`|`null` | Separator to use between number and unit. Default value to `''`. |
|
|
74
|
+
|
|
75
|
+
**Returns**
|
|
76
|
+
|
|
77
|
+
| Name | Type | Description |
|
|
78
|
+
|---------|------------------|-------------------------------------------------|
|
|
79
|
+
| results | `string`|`null` | Return null upon error. String value otherwise. |
|
|
80
|
+
|
|
81
|
+
**Example**
|
|
82
|
+
|
|
83
|
+
```js
|
|
84
|
+
bytes.format(1024);
|
|
85
|
+
// output: '1KB'
|
|
86
|
+
|
|
87
|
+
bytes.format(1000);
|
|
88
|
+
// output: '1000B'
|
|
89
|
+
|
|
90
|
+
bytes.format(1000, {thousandsSeparator: ' '});
|
|
91
|
+
// output: '1 000B'
|
|
92
|
+
|
|
93
|
+
bytes.format(1024 * 1.7, {decimalPlaces: 0});
|
|
94
|
+
// output: '2KB'
|
|
95
|
+
|
|
96
|
+
bytes.format(1024, {unitSeparator: ' '});
|
|
97
|
+
// output: '1 KB'
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
#### bytes.parse(string|number value): number|null
|
|
101
|
+
|
|
102
|
+
Parse the string value into an integer in bytes. If no unit is given, or `value`
|
|
103
|
+
is a number, it is assumed the value is in bytes.
|
|
104
|
+
|
|
105
|
+
Supported units and abbreviations are as follows and are case-insensitive:
|
|
106
|
+
|
|
107
|
+
* `b` for bytes
|
|
108
|
+
* `kb` for kilobytes
|
|
109
|
+
* `mb` for megabytes
|
|
110
|
+
* `gb` for gigabytes
|
|
111
|
+
* `tb` for terabytes
|
|
112
|
+
* `pb` for petabytes
|
|
113
|
+
|
|
114
|
+
The units are in powers of two, not ten. This means 1kb = 1024b according to this parser.
|
|
115
|
+
|
|
116
|
+
**Arguments**
|
|
117
|
+
|
|
118
|
+
| Name | Type | Description |
|
|
119
|
+
|---------------|--------|--------------------|
|
|
120
|
+
| value | `string`|`number` | String to parse, or number in bytes. |
|
|
121
|
+
|
|
122
|
+
**Returns**
|
|
123
|
+
|
|
124
|
+
| Name | Type | Description |
|
|
125
|
+
|---------|-------------|-------------------------|
|
|
126
|
+
| results | `number`|`null` | Return null upon error. Value in bytes otherwise. |
|
|
127
|
+
|
|
128
|
+
**Example**
|
|
129
|
+
|
|
130
|
+
```js
|
|
131
|
+
bytes.parse('1KB');
|
|
132
|
+
// output: 1024
|
|
133
|
+
|
|
134
|
+
bytes.parse('1024');
|
|
135
|
+
// output: 1024
|
|
136
|
+
|
|
137
|
+
bytes.parse(1024);
|
|
138
|
+
// output: 1024
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## License
|
|
142
|
+
|
|
143
|
+
[MIT](LICENSE)
|
|
144
|
+
|
|
145
|
+
[ci-image]: https://badgen.net/github/checks/visionmedia/bytes.js/master?label=ci
|
|
146
|
+
[ci-url]: https://github.com/visionmedia/bytes.js/actions?query=workflow%3Aci
|
|
147
|
+
[coveralls-image]: https://badgen.net/coveralls/c/github/visionmedia/bytes.js/master
|
|
148
|
+
[coveralls-url]: https://coveralls.io/r/visionmedia/bytes.js?branch=master
|
|
149
|
+
[downloads-image]: https://badgen.net/npm/dm/bytes
|
|
150
|
+
[downloads-url]: https://npmjs.org/package/bytes
|
|
151
|
+
[npm-image]: https://badgen.net/npm/v/bytes
|
|
152
|
+
[npm-url]: https://npmjs.org/package/bytes
|