Comparing version 0.0.1 to 0.1.0
@@ -41,2 +41,6 @@ var wk = function (c, msg, transfer, cb) { | ||
}; | ||
// optional chaining | ||
var chainWrap = function (name, expr, short) { | ||
return "(" + expr + "||(" + short + "={}))" + name; | ||
}; | ||
var encoder = { | ||
@@ -165,8 +169,22 @@ undefined: function () { return 'void 0'; }, | ||
var key = depNames[i], value = depValues[i]; | ||
var parts = key | ||
.replace(/\\/, '') | ||
.match(/^(.*?)(?=(\.|\[|$))|\[(.*?)\]|(\.(.*?))(?=(\.|\[|$))/g); | ||
var v = encoder[typeof value](value, reg, ab); | ||
if (typeof v == 'string') { | ||
out += "self[" + encoder.string(key) + "]=" + v + ";"; | ||
var pfx = 'self.' + parts[0]; | ||
var chain = pfx; | ||
for (var i_1 = 1; i_1 < parts.length; ++i_1) { | ||
chain = chainWrap(parts[i_1], chain, pfx); | ||
pfx += parts[i_1]; | ||
} | ||
out += chain + "=" + v + ";"; | ||
} | ||
else { | ||
dat[key] = v; | ||
// TODO: overwrite instead of assign | ||
var obj = dat; | ||
for (var i_2 = 0; i_2 < parts.length - 1; ++i_2) { | ||
obj = obj[parts[i_2]] = {}; | ||
} | ||
obj[parts[parts.length - 1]] = v; | ||
} | ||
@@ -173,0 +191,0 @@ } |
@@ -44,2 +44,6 @@ "use strict"; | ||
}; | ||
// optional chaining | ||
var chainWrap = function (name, expr, short) { | ||
return "(" + expr + "||(" + short + "={}))" + name; | ||
}; | ||
var encoder = { | ||
@@ -168,8 +172,22 @@ undefined: function () { return 'void 0'; }, | ||
var key = depNames[i], value = depValues[i]; | ||
var parts = key | ||
.replace(/\\/, '') | ||
.match(/^(.*?)(?=(\.|\[|$))|\[(.*?)\]|(\.(.*?))(?=(\.|\[|$))/g); | ||
var v = encoder[typeof value](value, reg, ab); | ||
if (typeof v == 'string') { | ||
out += "self[" + encoder.string(key) + "]=" + v + ";"; | ||
var pfx = 'self.' + parts[0]; | ||
var chain = pfx; | ||
for (var i_1 = 1; i_1 < parts.length; ++i_1) { | ||
chain = chainWrap(parts[i_1], chain, pfx); | ||
pfx += parts[i_1]; | ||
} | ||
out += chain + "=" + v + ";"; | ||
} | ||
else { | ||
dat[key] = v; | ||
// TODO: overwrite instead of assign | ||
var obj = dat; | ||
for (var i_2 = 0; i_2 < parts.length - 1; ++i_2) { | ||
obj = obj[parts[i_2]] = {}; | ||
} | ||
obj[parts[parts.length - 1]] = v; | ||
} | ||
@@ -176,0 +194,0 @@ } |
@@ -30,2 +30,6 @@ "use strict"; | ||
}; | ||
// optional chaining | ||
var chainWrap = function (name, expr, short) { | ||
return "(" + expr + "||(" + short + "={}))" + name; | ||
}; | ||
var encoder = { | ||
@@ -154,8 +158,22 @@ undefined: function () { return 'void 0'; }, | ||
var key = depNames[i], value = depValues[i]; | ||
var parts = key | ||
.replace(/\\/, '') | ||
.match(/^(.*?)(?=(\.|\[|$))|\[(.*?)\]|(\.(.*?))(?=(\.|\[|$))/g); | ||
var v = encoder[typeof value](value, reg, ab); | ||
if (typeof v == 'string') { | ||
out += "self[" + encoder.string(key) + "]=" + v + ";"; | ||
var pfx = 'self.' + parts[0]; | ||
var chain = pfx; | ||
for (var i_1 = 1; i_1 < parts.length; ++i_1) { | ||
chain = chainWrap(parts[i_1], chain, pfx); | ||
pfx += parts[i_1]; | ||
} | ||
out += chain + "=" + v + ";"; | ||
} | ||
else { | ||
dat[key] = v; | ||
// TODO: overwrite instead of assign | ||
var obj = dat; | ||
for (var i_2 = 0; i_2 < parts.length - 1; ++i_2) { | ||
obj = obj[parts[i_2]] = {}; | ||
} | ||
obj[parts[parts.length - 1]] = v; | ||
} | ||
@@ -162,0 +180,0 @@ } |
@@ -45,2 +45,6 @@ "use strict"; | ||
}; | ||
// optional chaining | ||
var chainWrap = function (name, expr, short) { | ||
return "(" + expr + "||(" + short + "={}))" + name; | ||
}; | ||
var encoder = { | ||
@@ -169,8 +173,22 @@ undefined: function () { return 'void 0'; }, | ||
var key = depNames[i], value = depValues[i]; | ||
var parts = key | ||
.replace(/\\/, '') | ||
.match(/^(.*?)(?=(\.|\[|$))|\[(.*?)\]|(\.(.*?))(?=(\.|\[|$))/g); | ||
var v = encoder[typeof value](value, reg, ab); | ||
if (typeof v == 'string') { | ||
out += "self[" + encoder.string(key) + "]=" + v + ";"; | ||
var pfx = 'self.' + parts[0]; | ||
var chain = pfx; | ||
for (var i_1 = 1; i_1 < parts.length; ++i_1) { | ||
chain = chainWrap(parts[i_1], chain, pfx); | ||
pfx += parts[i_1]; | ||
} | ||
out += chain + "=" + v + ";"; | ||
} | ||
else { | ||
dat[key] = v; | ||
// TODO: overwrite instead of assign | ||
var obj = dat; | ||
for (var i_2 = 0; i_2 < parts.length - 1; ++i_2) { | ||
obj = obj[parts[i_2]] = {}; | ||
} | ||
obj[parts[parts.length - 1]] = v; | ||
} | ||
@@ -177,0 +195,0 @@ } |
{ | ||
"name": "isoworker", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Isomorphic workerization with dependencies", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -18,3 +18,3 @@ # isoworker | ||
Install: | ||
``` | ||
```sh | ||
npm i isoworker # or yarn add isoworker, or pnpm add isoworker | ||
@@ -21,0 +21,0 @@ ``` |
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
53863
1269