@quilted/threads
Advanced tools
Comparing version 0.1.14 to 0.1.15
# @quilted/threads | ||
## 0.1.15 | ||
### Patch Changes | ||
- [`54e3db19`](https://github.com/lemonmade/quilt/commit/54e3db19094207d5eb5a073cfdbe98cb9ca68372) Thanks [@lemonmade](https://github.com/lemonmade)! - Encode more native JS types | ||
## 0.1.14 | ||
@@ -4,0 +10,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"type": "module", | ||
"version": "0.1.14", | ||
"version": "0.1.15", | ||
"license": "MIT", | ||
@@ -8,0 +8,0 @@ "engines": { |
@@ -21,2 +21,6 @@ import { | ||
const FUNCTION = '_@f'; | ||
const MAP = '_@m'; | ||
const SET = '_@s'; | ||
const DATE = '_@d'; | ||
const REGEXP = '_@r'; | ||
const ASYNC_ITERATOR = '_@i'; | ||
@@ -131,3 +135,3 @@ | ||
return [result, transferables]; | ||
return fullResult; | ||
} | ||
@@ -139,6 +143,37 @@ | ||
seen.set(value, fullResult); | ||
return fullResult; | ||
} | ||
if (value instanceof RegExp) { | ||
const result = [{[REGEXP]: [value.source, value.flags]}]; | ||
const fullResult: EncodeResult = [result, transferables]; | ||
seen.set(value, fullResult); | ||
return fullResult; | ||
} | ||
if (value instanceof Date) { | ||
const result = [{[DATE]: value.toISOString()}]; | ||
const fullResult: EncodeResult = [result, transferables]; | ||
seen.set(value, fullResult); | ||
return fullResult; | ||
} | ||
if (value instanceof Map) { | ||
const entries = [...value.entries()].map(([key, value]) => { | ||
return [encodeValue(key), encodeValue(value)]; | ||
}); | ||
const result = [{[MAP]: entries}]; | ||
const fullResult: EncodeResult = [result, transferables]; | ||
seen.set(value, fullResult); | ||
return fullResult; | ||
} | ||
if (value instanceof Set) { | ||
const entries = [...value].map((entry) => encodeValue(entry)); | ||
const result = [{[SET]: entries}]; | ||
const fullResult: EncodeResult = [result, transferables]; | ||
seen.set(value, fullResult); | ||
return fullResult; | ||
} | ||
const valueIsIterator = isIterator(value); | ||
@@ -209,2 +244,27 @@ | ||
if (REGEXP in value) { | ||
return new RegExp(...(value as {[REGEXP]: [string, string]})[REGEXP]); | ||
} | ||
if (DATE in value) { | ||
return new Date((value as {[DATE]: string})[DATE]); | ||
} | ||
if (MAP in value) { | ||
return new Map( | ||
(value as {[MAP]: [any, any]})[MAP].map(([key, value]) => [ | ||
decode(key, retainedBy), | ||
decode(value, retainedBy), | ||
]), | ||
); | ||
} | ||
if (SET in value) { | ||
return new Set( | ||
(value as {[SET]: any[]})[SET].map((entry) => | ||
decode(entry, retainedBy), | ||
), | ||
); | ||
} | ||
if (FUNCTION in value) { | ||
@@ -211,0 +271,0 @@ const id = (value as {[FUNCTION]: string})[FUNCTION]; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
174098
3129