static-params
Advanced tools
Comparing version 0.3.0 to 0.4.0
@@ -15,3 +15,3 @@ 'use strict'; | ||
t.push(...values[i].slice(1).map(_ => ',')); | ||
v.push(...values[i]); | ||
v.push(...(values[i].length ? values[i] : [''])) | ||
} | ||
@@ -18,0 +18,0 @@ else |
@@ -1,1 +0,1 @@ | ||
self.staticParams=function(t){"use strict";const n=new WeakMap,a=(t,...a)=>{const{t:e,v:r}=s(t,a),c=n.get(t)||n.set(t,{}).get(t);return(c[e]||(c[e]=[e])).concat(r.map(t=>a[t]))},s=(t,n)=>{const a=[t[0]],s=[];for(let r=0,c=0,i=0,{length:o}=n;c<o;c++)n[c]instanceof e?a[r]+=n[c].v+t[c+1]:(s[i++]=c,a[++r]=t[c+1]);return{t:a,v:s}};function e(t){this.v=t}return t.asParams=a,t.asStatic=t=>new e(t),t.asTag=t=>function(){return t.apply(this,a.apply(null,arguments))},t}({}); | ||
self.staticParams=function(t){"use strict";const e=new WeakMap,n=(t,...n)=>{const{t:s,v:r}=a(t,n),c=e.get(t)||e.set(t,{}).get(t);return(c[s]||(c[s]=[s])).concat(r.map(t=>n[t]))},a=(t,e)=>{const n=[t[0]],a=[];for(let r=0,c=0,o=0,{length:u}=e;c<u;c++)e[c]instanceof s?n[r]+=e[c].v+t[c+1]:(a[o++]=c,n[++r]=t[c+1]);return{t:n,v:a}};function s(t){this.v=t}return t.asParams=n,t.asStatic=t=>new s(t),t.asTag=t=>function(){return t.apply(this,n.apply(null,arguments))},Object.defineProperty(t,"__esModule",{value:!0}),t}({}); |
@@ -14,3 +14,3 @@ const {isArray} = Array; | ||
t.push(...values[i].slice(1).map(_ => ',')); | ||
v.push(...values[i]); | ||
v.push(...(values[i].length ? values[i] : [''])) | ||
} | ||
@@ -17,0 +17,0 @@ else |
17
index.js
@@ -5,3 +5,2 @@ self.staticParams = (function (exports) { | ||
var cache = new WeakMap(); | ||
var asTag = function asTag(fn) { | ||
@@ -12,3 +11,2 @@ return function () { | ||
}; | ||
var asParams = function asParams(template) { | ||
@@ -18,7 +16,5 @@ for (var _len = arguments.length, values = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
} | ||
var _parse = parse(template, values), | ||
t = _parse.t, | ||
v = _parse.v; | ||
t = _parse.t, | ||
v = _parse.v; | ||
var parsed = cache.get(template) || cache.set(template, {}).get(template); | ||
@@ -29,7 +25,5 @@ return (parsed[t] || (parsed[t] = [t])).concat(v.map(function (i) { | ||
}; | ||
var parse = function parse(template, values) { | ||
var t = [template[0]]; | ||
var v = []; | ||
for (var c = 0, i = 0, j = 0, length = values.length; i < length; i++) { | ||
@@ -41,3 +35,2 @@ if (values[i] instanceof Static) t[c] += values[i].v + template[i + 1];else { | ||
} | ||
return { | ||
@@ -48,7 +41,5 @@ t: t, | ||
}; | ||
var asStatic = function asStatic(value) { | ||
return new Static(value); | ||
}; | ||
function Static(v) { | ||
@@ -62,4 +53,6 @@ this.v = v; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
return exports; | ||
}({})); | ||
})({}); |
@@ -1,1 +0,1 @@ | ||
self.staticParams=function(n){"use strict";var t=new WeakMap,r=function(n){for(var r=arguments.length,e=new Array(r>1?r-1:0),u=1;u<r;u++)e[u-1]=arguments[u];var c=a(n,e),i=c.t,s=c.v,f=t.get(n)||t.set(n,{}).get(n);return(f[i]||(f[i]=[i])).concat(s.map((function(n){return e[n]})))},a=function(n,t){for(var r=[n[0]],a=[],u=0,c=0,i=0,s=t.length;c<s;c++)t[c]instanceof e?r[u]+=t[c].v+n[c+1]:(a[i++]=c,r[++u]=n[c+1]);return{t:r,v:a}};function e(n){this.v=n}return n.asParams=r,n.asStatic=function(n){return new e(n)},n.asTag=function(n){return function(){return n.apply(this,r.apply(null,arguments))}},n}({}); | ||
self.staticParams=function(t){"use strict";var n=new WeakMap,r=function(t){for(var r=arguments.length,a=new Array(r>1?r-1:0),u=1;u<r;u++)a[u-1]=arguments[u];var c=e(t,a),i=c.t,o=c.v,s=n.get(t)||n.set(t,{}).get(t);return(s[i]||(s[i]=[i])).concat(o.map((function(t){return a[t]})))},e=function(t,n){for(var r=[t[0]],e=[],u=0,c=0,i=0,o=n.length;c<o;c++)n[c]instanceof a?r[u]+=n[c].v+t[c+1]:(e[i++]=c,r[++u]=t[c+1]);return{t:r,v:e}};function a(t){this.v=t}return t.asParams=r,t.asStatic=function(t){return new a(t)},t.asTag=function(t){return function(){return t.apply(this,r.apply(null,arguments))}},Object.defineProperty(t,"__esModule",{value:!0}),t}({}); |
{ | ||
"name": "static-params", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "A general purpose utility to allow interpolation values as static parts of a template literal tag", | ||
@@ -5,0 +5,0 @@ "main": "./cjs/index.js", |
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
14457
205