@stryke/cookie 0.1.24 → 0.1.26
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 +14 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +1 -1
- package/dist/parse.cjs +1 -1
- package/dist/parse.d.cts +23 -2
- package/dist/parse.d.cts.map +1 -0
- package/dist/parse.d.mts +23 -2
- package/dist/parse.d.mts.map +1 -0
- package/dist/parse.mjs +2 -1
- package/dist/parse.mjs.map +1 -0
- package/dist/split.cjs +1 -1
- package/dist/split.d.cts +5 -2
- package/dist/split.d.cts.map +1 -0
- package/dist/split.d.mts +5 -2
- package/dist/split.d.mts.map +1 -0
- package/dist/split.mjs +2 -1
- package/dist/split.mjs.map +1 -0
- package/dist/stringify.cjs +1 -1
- package/dist/stringify.d.cts +16 -2
- package/dist/stringify.d.cts.map +1 -0
- package/dist/stringify.d.mts +16 -2
- package/dist/stringify.d.mts.map +1 -0
- package/dist/stringify.mjs +2 -1
- package/dist/stringify.mjs.map +1 -0
- package/dist/type-checks/src/get-object-tag.cjs +1 -0
- package/dist/type-checks/src/get-object-tag.mjs +2 -0
- package/dist/type-checks/src/get-object-tag.mjs.map +1 -0
- package/dist/type-checks/src/index.cjs +1 -0
- package/dist/type-checks/src/index.mjs +1 -0
- package/dist/type-checks/src/is-buffer.cjs +1 -0
- package/dist/type-checks/src/is-buffer.mjs +2 -0
- package/dist/type-checks/src/is-buffer.mjs.map +1 -0
- package/dist/type-checks/src/is-collection.cjs +1 -0
- package/dist/type-checks/src/is-collection.mjs +1 -0
- package/dist/type-checks/src/is-date.cjs +1 -0
- package/dist/type-checks/src/is-date.mjs +2 -0
- package/dist/type-checks/src/is-date.mjs.map +1 -0
- package/dist/type-checks/src/is-empty.cjs +1 -0
- package/dist/type-checks/src/is-empty.mjs +2 -0
- package/dist/type-checks/src/is-empty.mjs.map +1 -0
- package/dist/type-checks/src/is-function.cjs +1 -0
- package/dist/type-checks/src/is-function.mjs +2 -0
- package/dist/type-checks/src/is-function.mjs.map +1 -0
- package/dist/type-checks/src/is-null.cjs +1 -0
- package/dist/type-checks/src/is-null.mjs +2 -0
- package/dist/type-checks/src/is-null.mjs.map +1 -0
- package/dist/type-checks/src/is-plain-object.cjs +1 -0
- package/dist/type-checks/src/is-plain-object.mjs +2 -0
- package/dist/type-checks/src/is-plain-object.mjs.map +1 -0
- package/dist/type-checks/src/is-set.cjs +1 -0
- package/dist/type-checks/src/is-set.mjs +2 -0
- package/dist/type-checks/src/is-set.mjs.map +1 -0
- package/dist/{is-string-Cdq5ranA.mjs → type-checks/src/is-string.cjs} +1 -2
- package/dist/type-checks/src/is-string.mjs +2 -0
- package/dist/type-checks/src/is-string.mjs.map +1 -0
- package/dist/type-checks/src/is-undefined.cjs +1 -0
- package/dist/type-checks/src/is-undefined.mjs +2 -0
- package/dist/type-checks/src/is-undefined.mjs.map +1 -0
- package/dist/type-checks/src/type-detect.cjs +1 -0
- package/dist/type-checks/src/type-detect.mjs +2 -0
- package/dist/type-checks/src/type-detect.mjs.map +1 -0
- package/dist/types.d.cts +188 -2
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +188 -2
- package/dist/types.d.mts.map +1 -0
- package/package.json +5 -5
- package/dist/is-string-Cdq5ranA.mjs.map +0 -1
- package/dist/is-string-qyWqKQj-.cjs +0 -1
- package/dist/parse-CB7V9-FM.mjs +0 -2
- package/dist/parse-CB7V9-FM.mjs.map +0 -1
- package/dist/parse-CC7RDu95.d.cts +0 -23
- package/dist/parse-CC7RDu95.d.cts.map +0 -1
- package/dist/parse-DClQAhyZ.d.mts +0 -23
- package/dist/parse-DClQAhyZ.d.mts.map +0 -1
- package/dist/parse-Lu_9IylD.cjs +0 -1
- package/dist/split-BMQx0Ga2.d.mts +0 -5
- package/dist/split-BMQx0Ga2.d.mts.map +0 -1
- package/dist/split-DGuM3LaG.cjs +0 -1
- package/dist/split-DyNIhQJp.mjs +0 -2
- package/dist/split-DyNIhQJp.mjs.map +0 -1
- package/dist/split-Y8qgB1su.d.cts +0 -5
- package/dist/split-Y8qgB1su.d.cts.map +0 -1
- package/dist/src-Bw3xE0BI.mjs +0 -2
- package/dist/src-Bw3xE0BI.mjs.map +0 -1
- package/dist/src-C0Osv7A0.cjs +0 -1
- package/dist/stringify-BkjTv8_W.mjs +0 -2
- package/dist/stringify-BkjTv8_W.mjs.map +0 -1
- package/dist/stringify-DGdYwk9z.d.mts +0 -16
- package/dist/stringify-DGdYwk9z.d.mts.map +0 -1
- package/dist/stringify-f5GFtoll.cjs +0 -1
- package/dist/stringify-iqRz2xah.d.cts +0 -16
- package/dist/stringify-iqRz2xah.d.cts.map +0 -1
- package/dist/types-DfXe0PRY.d.mts +0 -188
- package/dist/types-DfXe0PRY.d.mts.map +0 -1
- package/dist/types-DmPnClfS.d.cts +0 -188
- package/dist/types-DmPnClfS.d.cts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog for Stryke - Cookie
|
|
4
4
|
|
|
5
|
+
## [0.1.25](https://github.com/storm-software/stryke/releases/tag/cookie%400.1.25) (12/08/2025)
|
|
6
|
+
|
|
7
|
+
### Updated Dependencies
|
|
8
|
+
|
|
9
|
+
- Updated **type-checks** to **v0.5.9**
|
|
10
|
+
- Updated **convert** to **v0.6.24**
|
|
11
|
+
|
|
12
|
+
## [0.1.24](https://github.com/storm-software/stryke/releases/tag/cookie%400.1.24) (12/08/2025)
|
|
13
|
+
|
|
14
|
+
### Updated Dependencies
|
|
15
|
+
|
|
16
|
+
- Updated **type-checks** to **v0.5.8**
|
|
17
|
+
- Updated **convert** to **v0.6.23**
|
|
18
|
+
|
|
5
19
|
## [0.1.23](https://github.com/storm-software/stryke/releases/tag/cookie%400.1.23) (12/08/2025)
|
|
6
20
|
|
|
7
21
|
### Updated Dependencies
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require(`./parse.cjs`),t=require(`./split.cjs`),n=require(`./stringify.cjs`);exports.parseCookie=e.parseCookie,exports.parseSetCookie=e.parseSetCookie,exports.splitSetCookieString=t.splitSetCookieString,exports.stringifyCookie=n.stringifyCookie;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { CookieParseOptions, CookieSerializeOptions, SetCookie, SetCookieParseOptions } from "./types.cjs";
|
|
2
|
+
import { parseCookie, parseSetCookie } from "./parse.cjs";
|
|
3
|
+
import { splitSetCookieString } from "./split.cjs";
|
|
4
|
+
import { stringifyCookie } from "./stringify.cjs";
|
|
5
5
|
export { CookieParseOptions, CookieSerializeOptions, SetCookie, SetCookieParseOptions, parseCookie, parseSetCookie, splitSetCookieString, stringifyCookie };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { CookieParseOptions, CookieSerializeOptions, SetCookie, SetCookieParseOptions } from "./types.mjs";
|
|
2
|
+
import { parseCookie, parseSetCookie } from "./parse.mjs";
|
|
3
|
+
import { splitSetCookieString } from "./split.mjs";
|
|
4
|
+
import { stringifyCookie } from "./stringify.mjs";
|
|
5
5
|
export { CookieParseOptions, CookieSerializeOptions, SetCookie, SetCookieParseOptions, parseCookie, parseSetCookie, splitSetCookieString, stringifyCookie };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{parseCookie as e,parseSetCookie as t}from"./parse.mjs";import{splitSetCookieString as n}from"./split.mjs";import{stringifyCookie as r}from"./stringify.mjs";export{e as parseCookie,t as parseSetCookie,n as splitSetCookieString,r as stringifyCookie};
|
package/dist/parse.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`./src-
|
|
1
|
+
const e=require(`./type-checks/src/is-string.cjs`);require(`./type-checks/src/index.cjs`);function t(t,n){if(!e.isString(t))throw Error(`argument str must be a string`);let r={},i=n??{},a=i.decode??(e=>e.includes(`%`)?decodeURIComponent(e):e),o=0;for(;o<t.length;){let e=t.indexOf(`=`,o);if(e===-1)break;let n=t.indexOf(`;`,o);if(n===-1)n=t.length;else if(n<e){o=t.lastIndexOf(`;`,e-1)+1;continue}let s=t.slice(o,e).trim();if(i?.filter&&!i?.filter(s)){o=n+1;continue}if(r[s]===void 0){let i=t.slice(e+1,n).trim();i.codePointAt(0)===34&&(i=i.slice(1,-1));try{r[s]=a(i)}catch{r[s]=i}}o=n+1}return r}function n(t,n){let r=(t||``).split(`;`).filter(t=>e.isString(t)&&!!t.trim()),i=r.shift()||``,a=``,o=``,s=i.split(`=`);s.length>1?(a=s.shift(),o=s.join(`=`)):o=i;try{o=n?.decode===!1?o:(n?.decode??decodeURIComponent)(o)}catch{}let c={name:a,value:o};for(let e of r){let t=e.split(`=`),n=(t.shift()||``).trimStart().toLowerCase(),r=t.join(`=`);switch(n){case`expires`:c.expires=new Date(r);break;case`max-age`:c.maxAge=Number.parseInt(r,10);break;case`secure`:c.secure=!0;break;case`httponly`:c.httpOnly=!0;break;case`samesite`:c.sameSite=r;break;default:c[n]=r}}return c}exports.parseCookie=t,exports.parseSetCookie=n;
|
package/dist/parse.d.cts
CHANGED
|
@@ -1,2 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { CookieParseOptions, SetCookie, SetCookieParseOptions } from "./types.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/parse.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Parse an HTTP Cookie header string and returning an object of all cookie name-value pairs.
|
|
7
|
+
*
|
|
8
|
+
* @param cookie - the string representing a `Cookie` header value
|
|
9
|
+
* @param options - object containing parsing options
|
|
10
|
+
* @returns an object with the parsed cookies
|
|
11
|
+
*/
|
|
12
|
+
declare function parseCookie(cookie: string, options?: CookieParseOptions): Record<string, string>;
|
|
13
|
+
/**
|
|
14
|
+
* Parse a [Set-Cookie](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie) header string into an object.
|
|
15
|
+
*
|
|
16
|
+
* @param setCookieValue - the string representing a `Set-Cookie` header value
|
|
17
|
+
* @param options - object containing parsing options
|
|
18
|
+
* @returns an object with the parsed cookie
|
|
19
|
+
*/
|
|
20
|
+
declare function parseSetCookie(setCookieValue: string, options?: SetCookieParseOptions): SetCookie;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { parseCookie, parseSetCookie };
|
|
23
|
+
//# sourceMappingURL=parse.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.d.cts","names":[],"sources":["../src/parse.ts"],"sourcesContent":[],"mappings":";;;;;;AAgCA;AAsEA;;;;iBAtEgB,WAAA,2BAEJ,qBACT;;;;;;;;iBAmEa,cAAA,mCAEJ,wBACT"}
|
package/dist/parse.d.mts
CHANGED
|
@@ -1,2 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { CookieParseOptions, SetCookie, SetCookieParseOptions } from "./types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/parse.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Parse an HTTP Cookie header string and returning an object of all cookie name-value pairs.
|
|
7
|
+
*
|
|
8
|
+
* @param cookie - the string representing a `Cookie` header value
|
|
9
|
+
* @param options - object containing parsing options
|
|
10
|
+
* @returns an object with the parsed cookies
|
|
11
|
+
*/
|
|
12
|
+
declare function parseCookie(cookie: string, options?: CookieParseOptions): Record<string, string>;
|
|
13
|
+
/**
|
|
14
|
+
* Parse a [Set-Cookie](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie) header string into an object.
|
|
15
|
+
*
|
|
16
|
+
* @param setCookieValue - the string representing a `Set-Cookie` header value
|
|
17
|
+
* @param options - object containing parsing options
|
|
18
|
+
* @returns an object with the parsed cookie
|
|
19
|
+
*/
|
|
20
|
+
declare function parseSetCookie(setCookieValue: string, options?: SetCookieParseOptions): SetCookie;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { parseCookie, parseSetCookie };
|
|
23
|
+
//# sourceMappingURL=parse.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.d.mts","names":[],"sources":["../src/parse.ts"],"sourcesContent":[],"mappings":";;;;;;AAgCA;AAsEA;;;;iBAtEgB,WAAA,2BAEJ,qBACT;;;;;;;;iBAmEa,cAAA,mCAEJ,wBACT"}
|
package/dist/parse.mjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import"./src-
|
|
1
|
+
import{isString as e}from"./type-checks/src/is-string.mjs";import"./type-checks/src/index.mjs";function t(t,n){if(!e(t))throw Error(`argument str must be a string`);let r={},i=n??{},a=i.decode??(e=>e.includes(`%`)?decodeURIComponent(e):e),o=0;for(;o<t.length;){let e=t.indexOf(`=`,o);if(e===-1)break;let n=t.indexOf(`;`,o);if(n===-1)n=t.length;else if(n<e){o=t.lastIndexOf(`;`,e-1)+1;continue}let s=t.slice(o,e).trim();if(i?.filter&&!i?.filter(s)){o=n+1;continue}if(r[s]===void 0){let i=t.slice(e+1,n).trim();i.codePointAt(0)===34&&(i=i.slice(1,-1));try{r[s]=a(i)}catch{r[s]=i}}o=n+1}return r}function n(t,n){let r=(t||``).split(`;`).filter(t=>e(t)&&!!t.trim()),i=r.shift()||``,a=``,o=``,s=i.split(`=`);s.length>1?(a=s.shift(),o=s.join(`=`)):o=i;try{o=n?.decode===!1?o:(n?.decode??decodeURIComponent)(o)}catch{}let c={name:a,value:o};for(let e of r){let t=e.split(`=`),n=(t.shift()||``).trimStart().toLowerCase(),r=t.join(`=`);switch(n){case`expires`:c.expires=new Date(r);break;case`max-age`:c.maxAge=Number.parseInt(r,10);break;case`secure`:c.secure=!0;break;case`httponly`:c.httpOnly=!0;break;case`samesite`:c.sameSite=r;break;default:c[n]=r}}return c}export{t as parseCookie,n as parseSetCookie};
|
|
2
|
+
//# sourceMappingURL=parse.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.mjs","names":["cookie: SetCookie"],"sources":["../src/parse.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isString } from \"@stryke/type-checks\";\nimport type {\n CookieParseOptions,\n SetCookie,\n SetCookieParseOptions\n} from \"./types\";\n\n/**\n * Parse an HTTP Cookie header string and returning an object of all cookie name-value pairs.\n *\n * @param cookie - the string representing a `Cookie` header value\n * @param options - object containing parsing options\n * @returns an object with the parsed cookies\n */\nexport function parseCookie(\n cookie: string,\n options?: CookieParseOptions\n): Record<string, string> {\n if (!isString(cookie)) {\n throw new Error(\"argument str must be a string\");\n }\n\n const obj = {};\n const opt = options ?? {};\n const dec =\n opt.decode ??\n ((str: string) => (str.includes(\"%\") ? decodeURIComponent(str) : str));\n\n let index = 0;\n while (index < cookie.length) {\n const eqIdx = cookie.indexOf(\"=\", index);\n\n // no more cookie pairs\n if (eqIdx === -1) {\n break;\n }\n\n let endIdx = cookie.indexOf(\";\", index);\n\n if (endIdx === -1) {\n endIdx = cookie.length;\n } else if (endIdx < eqIdx) {\n // backtrack on prior semicolon\n index = cookie.lastIndexOf(\";\", eqIdx - 1) + 1;\n\n continue;\n }\n\n const key = cookie.slice(index, eqIdx).trim();\n if (opt?.filter && !opt?.filter(key)) {\n index = endIdx + 1;\n\n continue;\n }\n\n // only assign once\n if (undefined === obj[key as keyof typeof obj]) {\n let val = cookie.slice(eqIdx + 1, endIdx).trim();\n\n // quoted values\n if (val.codePointAt(0) === 0x22) {\n val = val.slice(1, -1);\n }\n\n try {\n (obj as any)[key] = dec(val);\n } catch {\n (obj as any)[key] = val;\n }\n }\n\n index = endIdx + 1;\n }\n\n return obj;\n}\n\n/**\n * Parse a [Set-Cookie](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie) header string into an object.\n *\n * @param setCookieValue - the string representing a `Set-Cookie` header value\n * @param options - object containing parsing options\n * @returns an object with the parsed cookie\n */\nexport function parseSetCookie(\n setCookieValue: string,\n options?: SetCookieParseOptions\n): SetCookie {\n const parts = (setCookieValue || \"\")\n .split(\";\")\n .filter(str => isString(str) && Boolean(str.trim()));\n\n const nameValuePairStr = parts.shift() || \"\";\n\n let name = \"\";\n let value = \"\";\n const nameValueArr = nameValuePairStr.split(\"=\");\n if (nameValueArr.length > 1) {\n name = nameValueArr.shift()!;\n // Everything after the first =, joined by a \"=\" if there was more than one part\n value = nameValueArr.join(\"=\");\n } else {\n value = nameValuePairStr;\n }\n\n try {\n value =\n options?.decode === false\n ? value\n : (options?.decode ?? decodeURIComponent)(value);\n } catch {\n // Do nothing\n }\n\n const cookie: SetCookie = {\n name,\n value\n };\n\n for (const part of parts) {\n const sides = part.split(\"=\");\n const partKey = (sides.shift() || \"\").trimStart().toLowerCase();\n const partValue = sides.join(\"=\");\n switch (partKey) {\n case \"expires\": {\n cookie.expires = new Date(partValue);\n break;\n }\n case \"max-age\": {\n cookie.maxAge = Number.parseInt(partValue, 10);\n break;\n }\n case \"secure\": {\n cookie.secure = true;\n break;\n }\n case \"httponly\": {\n cookie.httpOnly = true;\n break;\n }\n case \"samesite\": {\n cookie.sameSite = partValue as SetCookie[\"sameSite\"];\n break;\n }\n default: {\n cookie[partKey] = partValue;\n }\n }\n }\n\n return cookie;\n}\n"],"mappings":"+FAgCA,SAAgB,EACd,EACA,EACwB,CACxB,GAAI,CAAC,EAAS,EAAO,CACnB,MAAU,MAAM,gCAAgC,CAGlD,IAAM,EAAM,EAAE,CACR,EAAM,GAAW,EAAE,CACnB,EACJ,EAAI,SACF,GAAiB,EAAI,SAAS,IAAI,CAAG,mBAAmB,EAAI,CAAG,GAE/D,EAAQ,EACZ,KAAO,EAAQ,EAAO,QAAQ,CAC5B,IAAM,EAAQ,EAAO,QAAQ,IAAK,EAAM,CAGxC,GAAI,IAAU,GACZ,MAGF,IAAI,EAAS,EAAO,QAAQ,IAAK,EAAM,CAEvC,GAAI,IAAW,GACb,EAAS,EAAO,eACP,EAAS,EAAO,CAEzB,EAAQ,EAAO,YAAY,IAAK,EAAQ,EAAE,CAAG,EAE7C,SAGF,IAAM,EAAM,EAAO,MAAM,EAAO,EAAM,CAAC,MAAM,CAC7C,GAAI,GAAK,QAAU,CAAC,GAAK,OAAO,EAAI,CAAE,CACpC,EAAQ,EAAS,EAEjB,SAIF,GAAkB,EAAI,KAAlB,IAAA,GAA4C,CAC9C,IAAI,EAAM,EAAO,MAAM,EAAQ,EAAG,EAAO,CAAC,MAAM,CAG5C,EAAI,YAAY,EAAE,GAAK,KACzB,EAAM,EAAI,MAAM,EAAG,GAAG,EAGxB,GAAI,CACD,EAAY,GAAO,EAAI,EAAI,MACtB,CACL,EAAY,GAAO,GAIxB,EAAQ,EAAS,EAGnB,OAAO,EAUT,SAAgB,EACd,EACA,EACW,CACX,IAAM,GAAS,GAAkB,IAC9B,MAAM,IAAI,CACV,OAAO,GAAO,EAAS,EAAI,EAAI,EAAQ,EAAI,MAAM,CAAE,CAEhD,EAAmB,EAAM,OAAO,EAAI,GAEtC,EAAO,GACP,EAAQ,GACN,EAAe,EAAiB,MAAM,IAAI,CAC5C,EAAa,OAAS,GACxB,EAAO,EAAa,OAAO,CAE3B,EAAQ,EAAa,KAAK,IAAI,EAE9B,EAAQ,EAGV,GAAI,CACF,EACE,GAAS,SAAW,GAChB,GACC,GAAS,QAAU,oBAAoB,EAAM,MAC9C,EAIR,IAAMA,EAAoB,CACxB,OACA,QACD,CAED,IAAK,IAAM,KAAQ,EAAO,CACxB,IAAM,EAAQ,EAAK,MAAM,IAAI,CACvB,GAAW,EAAM,OAAO,EAAI,IAAI,WAAW,CAAC,aAAa,CACzD,EAAY,EAAM,KAAK,IAAI,CACjC,OAAQ,EAAR,CACE,IAAK,UACH,EAAO,QAAU,IAAI,KAAK,EAAU,CACpC,MAEF,IAAK,UACH,EAAO,OAAS,OAAO,SAAS,EAAW,GAAG,CAC9C,MAEF,IAAK,SACH,EAAO,OAAS,GAChB,MAEF,IAAK,WACH,EAAO,SAAW,GAClB,MAEF,IAAK,WACH,EAAO,SAAW,EAClB,MAEF,QACE,EAAO,GAAW,GAKxB,OAAO"}
|
package/dist/split.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`./
|
|
1
|
+
const e=require(`./type-checks/src/is-string.cjs`);function t(n){if(Array.isArray(n))return n.flatMap(e=>t(e));if(!e.isString(n))return[];let r=[],i=0,a,o,s,c,l,u=()=>{for(;i<n.length&&/\s/.test(n.charAt(i));)i+=1;return i<n.length},d=()=>(o=n.charAt(i),o!==`=`&&o!==`;`&&o!==`,`);for(;i<n.length;){for(a=i,l=!1;u();)if(o=n.charAt(i),o===`,`){for(s=i,i+=1,u(),c=i;i<n.length&&d();)i+=1;i<n.length&&n.charAt(i)===`=`?(l=!0,i=c,r.push(n.slice(a,s)),a=i):i=s+1}else i+=1;(!l||i>=n.length)&&r.push(n.slice(a))}return r}exports.splitSetCookieString=t;
|
package/dist/split.d.cts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/split.d.ts
|
|
2
|
+
declare function splitSetCookieString(strCookie: string | string[]): string[];
|
|
3
|
+
//#endregion
|
|
4
|
+
export { splitSetCookieString };
|
|
5
|
+
//# sourceMappingURL=split.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"split.d.cts","names":[],"sources":["../src/split.ts"],"sourcesContent":[],"mappings":";iBAsCgB,oBAAA"}
|
package/dist/split.d.mts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/split.d.ts
|
|
2
|
+
declare function splitSetCookieString(strCookie: string | string[]): string[];
|
|
3
|
+
//#endregion
|
|
4
|
+
export { splitSetCookieString };
|
|
5
|
+
//# sourceMappingURL=split.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"split.d.mts","names":[],"sources":["../src/split.ts"],"sourcesContent":[],"mappings":";iBAsCgB,oBAAA"}
|
package/dist/split.mjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{isString as e}from"./type-checks/src/is-string.mjs";function t(n){if(Array.isArray(n))return n.flatMap(e=>t(e));if(!e(n))return[];let r=[],i=0,a,o,s,c,l,u=()=>{for(;i<n.length&&/\s/.test(n.charAt(i));)i+=1;return i<n.length},d=()=>(o=n.charAt(i),o!==`=`&&o!==`;`&&o!==`,`);for(;i<n.length;){for(a=i,l=!1;u();)if(o=n.charAt(i),o===`,`){for(s=i,i+=1,u(),c=i;i<n.length&&d();)i+=1;i<n.length&&n.charAt(i)===`=`?(l=!0,i=c,r.push(n.slice(a,s)),a=i):i=s+1}else i+=1;(!l||i>=n.length)&&r.push(n.slice(a))}return r}export{t as splitSetCookieString};
|
|
2
|
+
//# sourceMappingURL=split.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"split.mjs","names":["cookiesStrings: string[]","pos: number","start: number","ch: string","lastComma: number","nextStart: number","cookiesSeparatorFound: boolean"],"sources":["../src/split.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isString } from \"@stryke/type-checks/is-string\";\n\n/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport function splitSetCookieString(strCookie: string | string[]): string[] {\n if (Array.isArray(strCookie)) {\n return strCookie.flatMap(c => splitSetCookieString(c));\n }\n\n if (!isString(strCookie)) {\n return [];\n }\n\n const cookiesStrings: string[] = [];\n let pos: number = 0;\n let start: number;\n let ch: string;\n let lastComma: number;\n let nextStart: number;\n let cookiesSeparatorFound: boolean;\n\n const skipWhitespace = () => {\n while (pos < strCookie.length && /\\s/.test(strCookie.charAt(pos))) {\n pos += 1;\n }\n return pos < strCookie.length;\n };\n\n const notSpecialChar = () => {\n ch = strCookie.charAt(pos);\n return ch !== \"=\" && ch !== \";\" && ch !== \",\";\n };\n\n while (pos < strCookie.length) {\n start = pos;\n cookiesSeparatorFound = false;\n\n while (skipWhitespace()) {\n ch = strCookie.charAt(pos);\n if (ch === \",\") {\n // ',' is a cookie separator if we have later first '=', not ';' or ','\n lastComma = pos;\n pos += 1;\n\n skipWhitespace();\n nextStart = pos;\n\n while (pos < strCookie.length && notSpecialChar()) {\n pos += 1;\n }\n\n // currently special character\n if (pos < strCookie.length && strCookie.charAt(pos) === \"=\") {\n // we found cookies separator\n cookiesSeparatorFound = true;\n // pos is inside the next cookie, so back up and return it.\n pos = nextStart;\n cookiesStrings.push(strCookie.slice(start, lastComma));\n start = pos;\n } else {\n // in param ',' or param separator ';',\n // we continue from that comma\n pos = lastComma + 1;\n }\n } else {\n pos += 1;\n }\n }\n\n if (!cookiesSeparatorFound || pos >= strCookie.length) {\n cookiesStrings.push(strCookie.slice(start));\n }\n }\n\n return cookiesStrings;\n}\n"],"mappings":"2DAsCA,SAAgB,EAAqB,EAAwC,CAC3E,GAAI,MAAM,QAAQ,EAAU,CAC1B,OAAO,EAAU,QAAQ,GAAK,EAAqB,EAAE,CAAC,CAGxD,GAAI,CAAC,EAAS,EAAU,CACtB,MAAO,EAAE,CAGX,IAAMA,EAA2B,EAAE,CAC/BC,EAAc,EACdC,EACAC,EACAC,EACAC,EACAC,EAEE,MAAuB,CAC3B,KAAO,EAAM,EAAU,QAAU,KAAK,KAAK,EAAU,OAAO,EAAI,CAAC,EAC/D,GAAO,EAET,OAAO,EAAM,EAAU,QAGnB,OACJ,EAAK,EAAU,OAAO,EAAI,CACnB,IAAO,KAAO,IAAO,KAAO,IAAO,KAG5C,KAAO,EAAM,EAAU,QAAQ,CAI7B,IAHA,EAAQ,EACR,EAAwB,GAEjB,GAAgB,EAErB,GADA,EAAK,EAAU,OAAO,EAAI,CACtB,IAAO,IAAK,CAQd,IANA,EAAY,EACZ,GAAO,EAEP,GAAgB,CAChB,EAAY,EAEL,EAAM,EAAU,QAAU,GAAgB,EAC/C,GAAO,EAIL,EAAM,EAAU,QAAU,EAAU,OAAO,EAAI,GAAK,KAEtD,EAAwB,GAExB,EAAM,EACN,EAAe,KAAK,EAAU,MAAM,EAAO,EAAU,CAAC,CACtD,EAAQ,GAIR,EAAM,EAAY,OAGpB,GAAO,GAIP,CAAC,GAAyB,GAAO,EAAU,SAC7C,EAAe,KAAK,EAAU,MAAM,EAAM,CAAC,CAI/C,OAAO"}
|
package/dist/stringify.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`./src-
|
|
1
|
+
const e=require(`./type-checks/src/is-date.cjs`),t=require(`./type-checks/src/is-function.cjs`),n=require(`./type-checks/src/is-string.cjs`),r=require(`./type-checks/src/is-set.cjs`);require(`./type-checks/src/index.cjs`);const i=/^[\t\u0020-\u007E\u0080-\u00FF]+$/;function a(a,o,s){let c=s??{},l=c.encode??encodeURIComponent;if(!t.isFunction(l))throw Error(`option encode is invalid`);if(!i.test(a))throw Error(`argument name is invalid`);let u=l(o);if(u&&!i.test(u))throw Error(`argument val is invalid`);let d=`${a}=${u}`;if(!r.isSet(c.maxAge)){let e=Number(c.maxAge);if(Number.isNaN(e)||!Number.isFinite(e))throw TypeError(`option maxAge is invalid`);d+=`; Max-Age=${Math.floor(e)}`}if(c.domain){if(!i.test(c.domain))throw Error(`option domain is invalid`);d+=`; Domain=${c.domain}`}if(c.path){if(!i.test(c.path))throw Error(`option path is invalid`);d+=`; Path=${c.path}`}if(c.expires){if(!e.isDate(c.expires)||Number.isNaN(c.expires.valueOf()))throw Error(`option expires is invalid`);d+=`; Expires=${c.expires.toUTCString()}`}if(c.httpOnly&&(d+=`; HttpOnly`),c.secure&&(d+=`; Secure`),c.priority)switch(n.isString(c.priority)?c.priority.toLowerCase():c.priority){case`low`:d+=`; Priority=Low`;break;case`medium`:d+=`; Priority=Medium`;break;case`high`:d+=`; Priority=High`;break;default:throw Error(`option priority is invalid`)}if(c.sameSite)switch(n.isString(c.sameSite)?c.sameSite.toLowerCase():c.sameSite){case!0:d+=`; SameSite=Strict`;break;case`lax`:d+=`; SameSite=Lax`;break;case`strict`:d+=`; SameSite=Strict`;break;case`none`:d+=`; SameSite=None`;break;default:throw Error(`option sameSite is invalid`)}return c.partitioned&&(d+=`; Partitioned`),d}exports.stringifyCookie=a;
|
package/dist/stringify.d.cts
CHANGED
|
@@ -1,2 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { CookieSerializeOptions } from "./types.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/stringify.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Serialize a cookie name-value pair into a `Set-Cookie` header string.
|
|
7
|
+
*
|
|
8
|
+
* @param name - the name for the cookie
|
|
9
|
+
* @param value - value to set the cookie to
|
|
10
|
+
* @param options - object containing serialization options
|
|
11
|
+
* @returns a `Set-Cookie` header string
|
|
12
|
+
*/
|
|
13
|
+
declare function stringifyCookie(name: string, value: string, options?: CookieSerializeOptions): string;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { stringifyCookie };
|
|
16
|
+
//# sourceMappingURL=stringify.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringify.d.cts","names":[],"sources":["../src/stringify.ts"],"sourcesContent":[],"mappings":";;;;;;AAuCA;;;;;;iBAAgB,eAAA,wCAGJ"}
|
package/dist/stringify.d.mts
CHANGED
|
@@ -1,2 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { CookieSerializeOptions } from "./types.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/stringify.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Serialize a cookie name-value pair into a `Set-Cookie` header string.
|
|
7
|
+
*
|
|
8
|
+
* @param name - the name for the cookie
|
|
9
|
+
* @param value - value to set the cookie to
|
|
10
|
+
* @param options - object containing serialization options
|
|
11
|
+
* @returns a `Set-Cookie` header string
|
|
12
|
+
*/
|
|
13
|
+
declare function stringifyCookie(name: string, value: string, options?: CookieSerializeOptions): string;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { stringifyCookie };
|
|
16
|
+
//# sourceMappingURL=stringify.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringify.d.mts","names":[],"sources":["../src/stringify.ts"],"sourcesContent":[],"mappings":";;;;;;AAuCA;;;;;;iBAAgB,eAAA,wCAGJ"}
|
package/dist/stringify.mjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import"./src-
|
|
1
|
+
import{isDate as e}from"./type-checks/src/is-date.mjs";import{isFunction as t}from"./type-checks/src/is-function.mjs";import{isString as n}from"./type-checks/src/is-string.mjs";import{isSet as r}from"./type-checks/src/is-set.mjs";import"./type-checks/src/index.mjs";const i=/^[\t\u0020-\u007E\u0080-\u00FF]+$/;function a(a,o,s){let c=s??{},l=c.encode??encodeURIComponent;if(!t(l))throw Error(`option encode is invalid`);if(!i.test(a))throw Error(`argument name is invalid`);let u=l(o);if(u&&!i.test(u))throw Error(`argument val is invalid`);let d=`${a}=${u}`;if(!r(c.maxAge)){let e=Number(c.maxAge);if(Number.isNaN(e)||!Number.isFinite(e))throw TypeError(`option maxAge is invalid`);d+=`; Max-Age=${Math.floor(e)}`}if(c.domain){if(!i.test(c.domain))throw Error(`option domain is invalid`);d+=`; Domain=${c.domain}`}if(c.path){if(!i.test(c.path))throw Error(`option path is invalid`);d+=`; Path=${c.path}`}if(c.expires){if(!e(c.expires)||Number.isNaN(c.expires.valueOf()))throw Error(`option expires is invalid`);d+=`; Expires=${c.expires.toUTCString()}`}if(c.httpOnly&&(d+=`; HttpOnly`),c.secure&&(d+=`; Secure`),c.priority)switch(n(c.priority)?c.priority.toLowerCase():c.priority){case`low`:d+=`; Priority=Low`;break;case`medium`:d+=`; Priority=Medium`;break;case`high`:d+=`; Priority=High`;break;default:throw Error(`option priority is invalid`)}if(c.sameSite)switch(n(c.sameSite)?c.sameSite.toLowerCase():c.sameSite){case!0:d+=`; SameSite=Strict`;break;case`lax`:d+=`; SameSite=Lax`;break;case`strict`:d+=`; SameSite=Strict`;break;case`none`:d+=`; SameSite=None`;break;default:throw Error(`option sameSite is invalid`)}return c.partitioned&&(d+=`; Partitioned`),d}export{a as stringifyCookie};
|
|
2
|
+
//# sourceMappingURL=stringify.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringify.mjs","names":[],"sources":["../src/stringify.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isDate, isFunction, isSet, isString } from \"@stryke/type-checks\";\nimport type { CookieSerializeOptions } from \"./types\";\n\n/**\n * RegExp to match field-content in RFC 7230 sec 3.2\n *\n * field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]\n * field-vchar = VCHAR / obs-text\n * obs-text = %x80-FF\n */\n\nconst fieldContentRegExp = /^[\\t\\u0020-\\u007E\\u0080-\\u00FF]+$/;\n\n/**\n * Serialize a cookie name-value pair into a `Set-Cookie` header string.\n *\n * @param name - the name for the cookie\n * @param value - value to set the cookie to\n * @param options - object containing serialization options\n * @returns a `Set-Cookie` header string\n */\nexport function stringifyCookie(\n name: string,\n value: string,\n options?: CookieSerializeOptions\n): string {\n const opt = options ?? {};\n const enc = opt.encode ?? encodeURIComponent;\n\n if (!isFunction(enc)) {\n throw new Error(\"option encode is invalid\");\n }\n\n if (!fieldContentRegExp.test(name)) {\n throw new Error(\"argument name is invalid\");\n }\n\n const encodedValue = enc(value);\n\n if (encodedValue && !fieldContentRegExp.test(encodedValue)) {\n throw new Error(\"argument val is invalid\");\n }\n\n let str = `${name}=${encodedValue}`;\n\n if (!isSet(opt.maxAge)) {\n const maxAge = Number(opt.maxAge);\n\n if (Number.isNaN(maxAge) || !Number.isFinite(maxAge)) {\n throw new TypeError(\"option maxAge is invalid\");\n }\n\n str += `; Max-Age=${Math.floor(maxAge)}`;\n }\n\n if (opt.domain) {\n if (!fieldContentRegExp.test(opt.domain)) {\n throw new Error(\"option domain is invalid\");\n }\n\n str += `; Domain=${opt.domain}`;\n }\n\n if (opt.path) {\n if (!fieldContentRegExp.test(opt.path)) {\n throw new Error(\"option path is invalid\");\n }\n\n str += `; Path=${opt.path}`;\n }\n\n if (opt.expires) {\n if (!isDate(opt.expires) || Number.isNaN(opt.expires.valueOf())) {\n throw new Error(\"option expires is invalid\");\n }\n\n str += `; Expires=${opt.expires.toUTCString()}`;\n }\n\n if (opt.httpOnly) {\n str += \"; HttpOnly\";\n }\n\n if (opt.secure) {\n str += \"; Secure\";\n }\n\n if (opt.priority) {\n const priority = isString(opt.priority)\n ? opt.priority.toLowerCase()\n : opt.priority;\n\n switch (priority) {\n case \"low\": {\n str += \"; Priority=Low\";\n break;\n }\n case \"medium\": {\n str += \"; Priority=Medium\";\n break;\n }\n case \"high\": {\n str += \"; Priority=High\";\n break;\n }\n default: {\n throw new Error(\"option priority is invalid\");\n }\n }\n }\n\n if (opt.sameSite) {\n const sameSite = isString(opt.sameSite)\n ? opt.sameSite.toLowerCase()\n : opt.sameSite;\n\n switch (sameSite) {\n case true: {\n str += \"; SameSite=Strict\";\n break;\n }\n case \"lax\": {\n str += \"; SameSite=Lax\";\n break;\n }\n case \"strict\": {\n str += \"; SameSite=Strict\";\n break;\n }\n case \"none\": {\n str += \"; SameSite=None\";\n break;\n }\n default: {\n throw new Error(\"option sameSite is invalid\");\n }\n }\n }\n\n if (opt.partitioned) {\n str += \"; Partitioned\";\n }\n\n return str;\n}\n"],"mappings":"0QA6BA,MAAM,EAAqB,oCAU3B,SAAgB,EACd,EACA,EACA,EACQ,CACR,IAAM,EAAM,GAAW,EAAE,CACnB,EAAM,EAAI,QAAU,mBAE1B,GAAI,CAAC,EAAW,EAAI,CAClB,MAAU,MAAM,2BAA2B,CAG7C,GAAI,CAAC,EAAmB,KAAK,EAAK,CAChC,MAAU,MAAM,2BAA2B,CAG7C,IAAM,EAAe,EAAI,EAAM,CAE/B,GAAI,GAAgB,CAAC,EAAmB,KAAK,EAAa,CACxD,MAAU,MAAM,0BAA0B,CAG5C,IAAI,EAAM,GAAG,EAAK,GAAG,IAErB,GAAI,CAAC,EAAM,EAAI,OAAO,CAAE,CACtB,IAAM,EAAS,OAAO,EAAI,OAAO,CAEjC,GAAI,OAAO,MAAM,EAAO,EAAI,CAAC,OAAO,SAAS,EAAO,CAClD,MAAU,UAAU,2BAA2B,CAGjD,GAAO,aAAa,KAAK,MAAM,EAAO,GAGxC,GAAI,EAAI,OAAQ,CACd,GAAI,CAAC,EAAmB,KAAK,EAAI,OAAO,CACtC,MAAU,MAAM,2BAA2B,CAG7C,GAAO,YAAY,EAAI,SAGzB,GAAI,EAAI,KAAM,CACZ,GAAI,CAAC,EAAmB,KAAK,EAAI,KAAK,CACpC,MAAU,MAAM,yBAAyB,CAG3C,GAAO,UAAU,EAAI,OAGvB,GAAI,EAAI,QAAS,CACf,GAAI,CAAC,EAAO,EAAI,QAAQ,EAAI,OAAO,MAAM,EAAI,QAAQ,SAAS,CAAC,CAC7D,MAAU,MAAM,4BAA4B,CAG9C,GAAO,aAAa,EAAI,QAAQ,aAAa,GAW/C,GARI,EAAI,WACN,GAAO,cAGL,EAAI,SACN,GAAO,YAGL,EAAI,SAKN,OAJiB,EAAS,EAAI,SAAS,CACnC,EAAI,SAAS,aAAa,CAC1B,EAAI,SAER,CACE,IAAK,MACH,GAAO,iBACP,MAEF,IAAK,SACH,GAAO,oBACP,MAEF,IAAK,OACH,GAAO,kBACP,MAEF,QACE,MAAU,MAAM,6BAA6B,CAKnD,GAAI,EAAI,SAKN,OAJiB,EAAS,EAAI,SAAS,CACnC,EAAI,SAAS,aAAa,CAC1B,EAAI,SAER,CACE,IAAK,GACH,GAAO,oBACP,MAEF,IAAK,MACH,GAAO,iBACP,MAEF,IAAK,SACH,GAAO,oBACP,MAEF,IAAK,OACH,GAAO,kBACP,MAEF,QACE,MAAU,MAAM,6BAA6B,CASnD,OAJI,EAAI,cACN,GAAO,iBAGF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=e=>e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e);exports.getObjectTag=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-object-tag.mjs","names":[],"sources":["../../../../type-checks/src/get-object-tag.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * Gets the `toStringTag` of `obj`.\n *\n * @param value - The obj to query.\n * @returns Returns the `toStringTag`.\n */\nexport const getObjectTag = (value: unknown): string => {\n if (value == null) {\n return value === undefined ? \"[object Undefined]\" : \"[object Null]\";\n }\n return Object.prototype.toString.call(value);\n};\n"],"mappings":"AAwBA,MAAa,EAAgB,GACvB,GAAS,KACJ,IAAU,IAAA,GAAY,qBAAuB,gBAE/C,OAAO,UAAU,SAAS,KAAK,EAAM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./get-object-tag.cjs`),t=require(`./is-plain-object.cjs`),n=require(`./is-date.cjs`),r=require(`./is-function.cjs`),i=require(`./is-null.cjs`),a=require(`./is-undefined.cjs`),o=require(`./is-empty.cjs`),s=require(`./is-buffer.cjs`);require(`./type-detect.cjs`),require(`./is-collection.cjs`);const c=require(`./is-string.cjs`),l=require(`./is-set.cjs`);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getObjectTag as e}from"./get-object-tag.mjs";import{isObjectLike as t}from"./is-plain-object.mjs";import{isDate as n}from"./is-date.mjs";import{isAsyncFunction as r,isFunction as i,isSyncFunction as a}from"./is-function.mjs";import{isNull as o}from"./is-null.mjs";import{isUndefined as s}from"./is-undefined.mjs";import{isEmpty as c}from"./is-empty.mjs";import{isBufferExists as l}from"./is-buffer.mjs";import"./type-detect.mjs";import"./is-collection.mjs";import{isString as u}from"./is-string.mjs";import{isSet as d}from"./is-set.mjs";export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=typeof Buffer<`u`,t=e?Buffer.isBuffer.bind(Buffer):function(e){return!1};exports.isBufferExists=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-buffer.mjs","names":["isBuffer: typeof Buffer.isBuffer","isBuffer"],"sources":["../../../../type-checks/src/is-buffer.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport const isBufferExists = typeof Buffer !== \"undefined\";\n\n/**\n * Check if the provided value's type is `Buffer`\n */\nexport const isBuffer: typeof Buffer.isBuffer = isBufferExists\n ? Buffer.isBuffer.bind(Buffer)\n : /**\n * Check if the provided value's type is `Buffer`\n\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `Buffer`\n */\n function isBuffer(\n value: Parameters<typeof Buffer.isBuffer>[0]\n ): value is Buffer {\n return false;\n };\n"],"mappings":"AAkBA,MAAa,EAAiB,OAAO,OAAW,IAKA,GAC5C,OAAO,SAAS,KAAK,OAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require(`./type-detect.cjs`);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./type-detect.mjs";export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./get-object-tag.cjs`),t=require(`./is-plain-object.cjs`),n=n=>t.isObjectLike(n)&&e.getObjectTag(n)==`[object Date]`;exports.isDate=n;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-date.mjs","names":[],"sources":["../../../../type-checks/src/is-date.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getObjectTag } from \"./get-object-tag\";\nimport { isObjectLike } from \"./is-plain-object\";\n\n/**\n * Checks if `value` is classified as a `Date` object.\n *\n * @example\n * ```typescript\n * isDate(new Date)\n * // => true\n *\n * isDate('Mon April 23 2012')\n * // => false\n * ```\n *\n * @param value - The value to check.\n * @returns Returns `true` if `obj` is a date object, else `false`.\n */\nexport const isDate = (value: unknown): value is Date =>\n isObjectLike(value) && getObjectTag(value) == \"[object Date]\";\n"],"mappings":"yGAoCA,MAAa,EAAU,GACrB,EAAa,EAAM,EAAI,EAAa,EAAM,EAAI"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./is-null.cjs`),t=require(`./is-undefined.cjs`),n=n=>{try{return t.isUndefined(n)||e.isNull(n)}catch{return!1}};exports.isEmpty=n;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-empty.mjs","names":[],"sources":["../../../../type-checks/src/is-empty.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isDate } from \"./is-date\";\nimport { isFunction } from \"./is-function\";\nimport { isNull } from \"./is-null\";\nimport { isNumber } from \"./is-number\";\nimport { isSymbol } from \"./is-symbol\";\nimport { isUndefined } from \"./is-undefined\";\n\n/**\n * Check if the provided value's type is `null` or `undefined`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `null` or `undefined`\n */\nexport const isEmpty = (value: unknown) => {\n try {\n return isUndefined(value) || isNull(value);\n } catch {\n return false;\n }\n};\n\nexport const isEmptyAnything = (value: any) => {\n if (value === true || value === false) return true;\n if (value === null || value === undefined) return true;\n if (isNumber(value)) return value === 0;\n if (isDate(value)) return Number.isNaN(value.getTime());\n if (isFunction(value)) return false;\n if (isSymbol(value)) return false;\n const { length } = value;\n if (isNumber(length)) return length === 0;\n const { size } = value;\n if (isNumber(size)) return size === 0;\n const keys = Object.keys(value).length;\n\n return keys === 0;\n};\n"],"mappings":"wFA+BA,MAAa,EAAW,GAAmB,CACzC,GAAI,CACF,OAAO,EAAY,EAAM,EAAI,EAAO,EAAM,MACpC,CACN,MAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./get-object-tag.cjs`);function t(t){return e.getObjectTag(t)===`[object Function]`}function n(t){return e.getObjectTag(t)===`[object AsyncFunction]`}const r=e=>{try{return e instanceof Function||typeof e==`function`||!!(e?.constructor&&e?.call&&e?.apply)||t(e)||n(e)}catch{return!1}};exports.isAsyncFunction=n,exports.isFunction=r,exports.isSyncFunction=t;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{getObjectTag as e}from"./get-object-tag.mjs";function t(t){return e(t)===`[object Function]`}function n(t){return e(t)===`[object AsyncFunction]`}const r=e=>{try{return e instanceof Function||typeof e==`function`||!!(e?.constructor&&e?.call&&e?.apply)||t(e)||n(e)}catch{return!1}};export{n as isAsyncFunction,r as isFunction,t as isSyncFunction};
|
|
2
|
+
//# sourceMappingURL=is-function.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-function.mjs","names":[],"sources":["../../../../type-checks/src/is-function.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { AnyFunction } from \"@stryke/types/base\";\nimport { getObjectTag } from \"./get-object-tag\";\n\nexport function isSyncFunction(value?: any): value is AnyFunction {\n return getObjectTag(value) === \"[object Function]\";\n}\n\nexport function isAsyncFunction(value?: any): value is AnyFunction {\n return getObjectTag(value) === \"[object AsyncFunction]\";\n}\n\n/**\n * Check if the provided value's type is `Function`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `Function`\n */\nexport const isFunction = (value: unknown): value is AnyFunction => {\n try {\n return (\n value instanceof Function ||\n typeof value === \"function\" ||\n Boolean(\n value?.constructor && (value as any)?.call && (value as any)?.apply\n ) ||\n isSyncFunction(value) ||\n isAsyncFunction(value)\n );\n } catch {\n return false;\n }\n};\n"],"mappings":"oDAqBA,SAAgB,EAAe,EAAmC,CAChE,OAAO,EAAa,EAAM,GAAK,oBAGjC,SAAgB,EAAgB,EAAmC,CACjE,OAAO,EAAa,EAAM,GAAK,yBASjC,MAAa,EAAc,GAAyC,CAClE,GAAI,CACF,OACE,aAAiB,UACjB,OAAO,GAAU,YACjB,GACE,GAAO,aAAgB,GAAe,MAAS,GAAe,QAEhE,EAAe,EAAM,EACrB,EAAgB,EAAM,MAElB,CACN,MAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=e=>{try{return e===null}catch{return!1}};exports.isNull=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-null.mjs","names":[],"sources":["../../../../type-checks/src/is-null.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport const isNull = (value: unknown): value is null => {\n try {\n return value === null;\n } catch {\n return false;\n }\n};\n"],"mappings":"AAkBA,MAAa,EAAU,GAAkC,CACvD,GAAI,CACF,OAAO,IAAU,UACX,CACN,MAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=e=>typeof e==`object`&&!!e;exports.isObjectLike=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-plain-object.mjs","names":[],"sources":["../../../../type-checks/src/is-plain-object.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { PlainObject } from \"@stryke/types/base\";\nimport { getObjectTag } from \"./get-object-tag\";\n\n/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @example\n * ```typescript\n * isObjectLike({})\n * // => true\n *\n * isObjectLike([1, 2, 3])\n * // => true\n *\n * isObjectLike(Function)\n * // => false\n *\n * isObjectLike(null)\n * // => false\n * ```\n *\n * @param value - The value to check.\n * @returns Returns `true` if `value` is object-like, else `false`.\n */\nexport const isObjectLike = (obj: unknown) => {\n return typeof obj === \"object\" && obj !== null;\n};\n\n/**\n * Checks if `obj` is a plain object, that is, an object created by the `Object` constructor or one with a `[[Prototype]]` of `null`.\n *\n * @example\n * ```typescript\n * function Foo() {\n * this.a = 1\n * }\n *\n * isPlainObject(new Foo)\n * // => false\n *\n * isPlainObject([1, 2, 3])\n * // => false\n *\n * isPlainObject({ 'x': 0, 'y': 0 })\n * // => true\n *\n * isPlainObject(Object.create(null))\n * // => true\n * ```\n *\n * @param obj - The value to check.\n * @returns Returns `true` if `obj` is a plain object, else `false`.\n */\nexport const isPlainObject = (obj: unknown): obj is PlainObject => {\n if (!isObjectLike(obj) || getObjectTag(obj) !== \"[object Object]\") {\n return false;\n }\n if (Object.getPrototypeOf(obj) === null) {\n return true;\n }\n let proto = obj;\n while (Object.getPrototypeOf(proto) !== null) {\n proto = Object.getPrototypeOf(proto);\n }\n return Object.getPrototypeOf(obj) === proto;\n};\n"],"mappings":"AA2CA,MAAa,EAAgB,GACpB,OAAO,GAAQ,YAAY"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./is-empty.cjs`),t=t=>{try{return!e.isEmpty(t)}catch{return!1}};exports.isSet=t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-set.mjs","names":[],"sources":["../../../../type-checks/src/is-set.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isEmpty } from \"./is-empty\";\n\n/**\n * The inverse of the `isEmpty` function\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is **NOT** of type `null` or `undefined`\n */\nexport const isSet = (value: unknown): value is NonNullable<unknown> => {\n try {\n return !isEmpty(value);\n } catch {\n return false;\n }\n};\n"],"mappings":"yCA0BA,MAAa,EAAS,GAAkD,CACtE,GAAI,CACF,MAAO,CAAC,EAAQ,EAAM,MAChB,CACN,MAAO"}
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
const e=e=>{try{return typeof e==`string`}catch{return!1}};
|
|
2
|
-
//# sourceMappingURL=is-string-Cdq5ranA.mjs.map
|
|
1
|
+
const e=e=>{try{return typeof e==`string`}catch{return!1}};exports.isString=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-string.mjs","names":[],"sources":["../../../../type-checks/src/is-string.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport const isString = (value: unknown): value is string => {\n try {\n return typeof value === \"string\";\n } catch {\n return false;\n }\n};\n"],"mappings":"AAkBA,MAAa,EAAY,GAAoC,CAC3D,GAAI,CACF,OAAO,OAAO,GAAU,cAClB,CACN,MAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=e=>e===void 0;exports.isUndefined=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-undefined.mjs","names":[],"sources":["../../../../type-checks/src/is-undefined.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport const isUndefined = (value: unknown): value is undefined => {\n return value === undefined;\n};\n"],"mappings":"AAkBA,MAAa,EAAe,GACnB,IAAU,IAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require(`./is-buffer.cjs`);const e=(e=>(typeof globalThis==`object`||Object.defineProperty(e,`typeDetectGlobalObject`,{get(){return this},configurable:!0}),globalThis))(Object.prototype);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-detect.mjs","names":[],"sources":["../../../../type-checks/src/type-detect.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isBuffer } from \"./is-buffer\";\n\nconst globalObject = (Obj => {\n if (typeof globalThis === \"object\") {\n return globalThis;\n }\n Object.defineProperty(Obj, \"typeDetectGlobalObject\", {\n get() {\n return this;\n },\n configurable: true\n });\n\n // // biome-ignore lint/correctness/noUndeclaredVariables: <explanation>\n // const global = typeDetectGlobalObject;\n\n // // biome-ignore lint/performance/noDelete: <explanation>\n // delete Obj.typeDetectGlobalObject;\n return globalThis;\n})(Object.prototype);\n\nexport function typeDetect(obj: unknown): string {\n // NOTE: isBuffer must execute before type-detect,\n // because type-detect returns 'Uint8Array'.\n if (isBuffer(obj)) {\n return \"Buffer\";\n }\n\n const typeofObj = typeof obj;\n if (typeofObj !== \"object\") {\n return typeofObj;\n }\n\n if (obj === null) {\n return \"null\";\n }\n\n if (obj === globalObject) {\n return \"global\";\n }\n\n if (\n Array.isArray(obj) &&\n (Symbol.toStringTag === undefined || !(Symbol.toStringTag in obj))\n ) {\n return \"Array\";\n }\n\n // https://html.spec.whatwg.org/multipage/browsers.html#location\n if (typeof globalThis === \"object\" && globalThis !== null) {\n if (\n typeof (globalThis as any).location === \"object\" &&\n obj === (globalThis as any).location\n ) {\n return \"Location\";\n }\n\n // https://html.spec.whatwg.org/#document\n if (\n typeof (globalThis as any).document === \"object\" &&\n obj === (globalThis as any).document\n ) {\n return \"Document\";\n }\n\n // https://html.spec.whatwg.org/multipage/webappapis.html#mimetypearray\n if (typeof (globalThis as any).navigator === \"object\") {\n if (\n typeof (globalThis as any).navigator.mimeTypes === \"object\" &&\n obj === (globalThis as any).navigator.mimeTypes\n ) {\n return \"MimeTypeArray\";\n }\n\n // https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray\n if (\n typeof (globalThis as any).navigator.plugins === \"object\" &&\n obj === (globalThis as any).navigator.plugins\n ) {\n return \"PluginArray\";\n }\n }\n\n // https://html.spec.whatwg.org/multipage/webappapis.html#pluginarray\n if (\n (typeof (globalThis as any).HTMLElement === \"function\" ||\n typeof (globalThis as any).HTMLElement === \"object\") &&\n obj instanceof (globalThis as any).HTMLElement\n ) {\n if ((obj as any).tagName === \"BLOCKQUOTE\") {\n return \"HTMLQuoteElement\";\n }\n\n // https://html.spec.whatwg.org/#htmltabledatacellelement\n if ((obj as any).tagName === \"TD\") {\n return \"HTMLTableDataCellElement\";\n }\n\n // https://html.spec.whatwg.org/#htmltableheadercellelement\n if ((obj as any).tagName === \"TH\") {\n return \"HTMLTableHeaderCellElement\";\n }\n }\n }\n\n const stringTag =\n Symbol.toStringTag !== undefined && (obj as any)[Symbol.toStringTag];\n if (typeof stringTag === \"string\") {\n return stringTag;\n }\n\n const objPrototype = Object.getPrototypeOf(obj);\n if (objPrototype === RegExp.prototype) {\n return \"RegExp\";\n }\n\n if (objPrototype === Date.prototype) {\n return \"Date\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-promise.prototype-@@tostringtag\n if (typeof Promise !== \"undefined\" && objPrototype === Promise.prototype) {\n return \"Promise\";\n }\n\n if (typeof Set !== \"undefined\" && objPrototype === Set.prototype) {\n return \"Set\";\n }\n\n if (typeof Map !== \"undefined\" && objPrototype === Map.prototype) {\n return \"Map\";\n }\n\n if (typeof WeakSet !== \"undefined\" && objPrototype === WeakSet.prototype) {\n return \"WeakSet\";\n }\n\n if (typeof WeakMap !== \"undefined\" && objPrototype === WeakMap.prototype) {\n return \"WeakMap\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-dataview.prototype-@@tostringtag\n if (typeof DataView !== \"undefined\" && objPrototype === DataView.prototype) {\n return \"DataView\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%mapiteratorprototype%-@@tostringtag\n if (\n typeof Map !== \"undefined\" &&\n objPrototype === Object.getPrototypeOf(new Map().entries())\n ) {\n return \"Map Iterator\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%setiteratorprototype%-@@tostringtag\n if (\n typeof Set !== \"undefined\" &&\n objPrototype === Object.getPrototypeOf(new Set().entries())\n ) {\n return \"Set Iterator\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%arrayiteratorprototype%-@@tostringtag\n if (\n typeof Array.prototype[Symbol.iterator] === \"function\" &&\n objPrototype === Object.getPrototypeOf([][Symbol.iterator]())\n ) {\n return \"Array Iterator\";\n }\n\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-%stringiteratorprototype%-@@tostringtag\n if (\n Symbol.iterator !== undefined &&\n typeof String.prototype[Symbol.iterator] === \"function\" &&\n Object.getPrototypeOf(\"\"[Symbol.iterator]()) &&\n objPrototype === Object.getPrototypeOf(\"\"[Symbol.iterator]())\n ) {\n return \"String Iterator\";\n }\n\n if (objPrototype === null) {\n return \"Object\";\n }\n\n return Object.prototype.toString.call(obj).slice(8, -1);\n}\n"],"mappings":"yBAoBsB,IAChB,OAAO,YAAe,UAG1B,OAAO,eAAe,EAAK,yBAA0B,CACnD,KAAM,CACJ,OAAO,MAET,aAAc,GACf,CAAC,CAPO,aAeR,OAAO,UAAU"}
|