Comparing version 1.3.0 to 1.4.0
@@ -1,2 +0,2 @@ | ||
var r,n=(r=require("dot-prop"))&&"object"==typeof r&&"default"in r?r.default:r;function t(r){return function(t){if(void 0!==r&&!n.has(t,String(r)))throw new TypeError(t+" has no property '"+r+"'");if(void 0===t)throw new TypeError("Context is undefined");return void 0===r?t:n.get(t,String(r))}}function o(r,n){void 0===n&&(n={});var o=n.join;void 0===o&&(o=", ");var e=n.lastJoin;return void 0===e&&(e=", "),function(n){var i=t(r)(n);if(!Array.isArray(i))throw new TypeError(i+" is not an array");return[i.slice(0,-1).join(o),i[i.length-1]].join(i.length<2?"":e)}}exports.fnt=function(r){for(var n=[],t=arguments.length-1;t-- >0;)n[t]=arguments[t+1];return function(t){return r.map(function(r,o){if(o>=n.length)return r;var e=n[o];return"function"==typeof e?r+e(t):r+e}).join("")}},exports.firstOf=function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return function(n){for(var t=0,o=r;t<o.length;t+=1){var e=o[t];try{return"function"==typeof e?e(n):e}catch(r){}}throw new TypeError("firstOf did not resolve to any of the given expressions")}},exports.get=t,exports.list=o,exports.listAnd=function(r){return o(r,{join:", ",lastJoin:", and "})},exports.listOr=function(r){return o(r,{join:", ",lastJoin:", or "})},exports.pipe=function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return function(n){return r.reduce(function(r,n){return n(r)},n)}}; | ||
var r,n=(r=require("dot-prop"))&&"object"==typeof r&&"default"in r?r.default:r;function t(r,t){if(void 0!==r&&!n.has(t,String(r)))throw new TypeError(t+" has no property '"+r+"'");if(void 0===t)throw new TypeError("Context is undefined");return void 0===r?t:n.get(t,String(r))}function o(r){return function(n){if(Array.isArray(r))return r.map(function(r){return t(r,n)});if("object"==typeof r){for(var o={},e=0,i=Object.entries(r);e<i.length;e+=1){var u=i[e];o[u[0]]=t(u[1],n)}return o}return t(r,n)}}function e(r,n){void 0===n&&(n={});var t=n.join;void 0===t&&(t=", ");var e=n.lastJoin;return void 0===e&&(e=", "),function(n){var i=o(r)(n);if(!Array.isArray(i))throw new TypeError(i+" is not an array");return[i.slice(0,-1).join(t),i[i.length-1]].join(i.length<2?"":e)}}exports.fnt=function(r){for(var n=[],t=arguments.length-1;t-- >0;)n[t]=arguments[t+1];return function(t){return r.map(function(r,o){if(o>=n.length)return r;var e=n[o];return"function"==typeof e?r+e(t):r+e}).join("")}},exports.firstOf=function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return function(n){for(var t=0,o=r;t<o.length;t+=1){var e=o[t];try{return"function"==typeof e?e(n):e}catch(r){}}throw new TypeError("firstOf did not resolve to any of the given expressions")}},exports.get=o,exports.guard=function(r){return function(n){if(!r(n))throw new TypeError(n+" does not satisfy the guard condition");return n}},exports.list=e,exports.listAnd=function(r){return e(r,{join:", ",lastJoin:", and "})},exports.listOr=function(r){return e(r,{join:", ",lastJoin:", or "})},exports.pipe=function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];return function(n){return r.reduce(function(r,n){return n(r)},n)}}; | ||
//# sourceMappingURL=fntstring.js.map |
@@ -1,2 +0,2 @@ | ||
!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("dot-prop")):"function"==typeof define&&define.amd?define(["exports","dot-prop"],r):r(n.fntstring={},n.dotProp)}(this,function(n,r){function t(n){return function(t){if(void 0!==n&&!r.has(t,String(n)))throw new TypeError(t+" has no property '"+n+"'");if(void 0===t)throw new TypeError("Context is undefined");return void 0===n?t:r.get(t,String(n))}}function o(n,r){void 0===r&&(r={});var o=r.join;void 0===o&&(o=", ");var e=r.lastJoin;return void 0===e&&(e=", "),function(r){var i=t(n)(r);if(!Array.isArray(i))throw new TypeError(i+" is not an array");return[i.slice(0,-1).join(o),i[i.length-1]].join(i.length<2?"":e)}}r=r&&r.hasOwnProperty("default")?r.default:r,n.fnt=function(n){for(var r=[],t=arguments.length-1;t-- >0;)r[t]=arguments[t+1];return function(t){return n.map(function(n,o){if(o>=r.length)return n;var e=r[o];return"function"==typeof e?n+e(t):n+e}).join("")}},n.firstOf=function(){for(var n=[],r=arguments.length;r--;)n[r]=arguments[r];return function(r){for(var t=0,o=n;t<o.length;t+=1){var e=o[t];try{return"function"==typeof e?e(r):e}catch(n){}}throw new TypeError("firstOf did not resolve to any of the given expressions")}},n.get=t,n.list=o,n.listAnd=function(n){return o(n,{join:", ",lastJoin:", and "})},n.listOr=function(n){return o(n,{join:", ",lastJoin:", or "})},n.pipe=function(){for(var n=[],r=arguments.length;r--;)n[r]=arguments[r];return function(r){return n.reduce(function(n,r){return r(n)},r)}}}); | ||
!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("dot-prop")):"function"==typeof define&&define.amd?define(["exports","dot-prop"],r):r(n.fntstring={},n.dotProp)}(this,function(n,r){function t(n,t){if(void 0!==n&&!r.has(t,String(n)))throw new TypeError(t+" has no property '"+n+"'");if(void 0===t)throw new TypeError("Context is undefined");return void 0===n?t:r.get(t,String(n))}function o(n){return function(r){if(Array.isArray(n))return n.map(function(n){return t(n,r)});if("object"==typeof n){for(var o={},e=0,i=Object.entries(n);e<i.length;e+=1){var f=i[e];o[f[0]]=t(f[1],r)}return o}return t(n,r)}}function e(n,r){void 0===r&&(r={});var t=r.join;void 0===t&&(t=", ");var e=r.lastJoin;return void 0===e&&(e=", "),function(r){var i=o(n)(r);if(!Array.isArray(i))throw new TypeError(i+" is not an array");return[i.slice(0,-1).join(t),i[i.length-1]].join(i.length<2?"":e)}}r=r&&r.hasOwnProperty("default")?r.default:r,n.fnt=function(n){for(var r=[],t=arguments.length-1;t-- >0;)r[t]=arguments[t+1];return function(t){return n.map(function(n,o){if(o>=r.length)return n;var e=r[o];return"function"==typeof e?n+e(t):n+e}).join("")}},n.firstOf=function(){for(var n=[],r=arguments.length;r--;)n[r]=arguments[r];return function(r){for(var t=0,o=n;t<o.length;t+=1){var e=o[t];try{return"function"==typeof e?e(r):e}catch(n){}}throw new TypeError("firstOf did not resolve to any of the given expressions")}},n.get=o,n.guard=function(n){return function(r){if(!n(r))throw new TypeError(r+" does not satisfy the guard condition");return r}},n.list=e,n.listAnd=function(n){return e(n,{join:", ",lastJoin:", and "})},n.listOr=function(n){return e(n,{join:", ",lastJoin:", or "})},n.pipe=function(){for(var n=[],r=arguments.length;r--;)n[r]=arguments[r];return function(r){return n.reduce(function(n,r){return r(n)},r)}}}); | ||
//# sourceMappingURL=fntstring.umd.js.map |
{ | ||
"name": "fntstring", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "Utilities for building template strings with complex interpolations", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
import dotProp from "dot-prop" | ||
function getSingleKey(key, context) { | ||
if (key !== undefined && !dotProp.has(context, String(key))) { | ||
throw new TypeError(`${context} has no property '${key}'`) | ||
} | ||
if (context === undefined) { | ||
throw new TypeError(`Context is undefined`) | ||
} | ||
if (key === undefined) { | ||
return context | ||
} | ||
return dotProp.get(context, String(key)) | ||
} | ||
export function get(key) { | ||
return context => { | ||
if (key !== undefined && !dotProp.has(context, String(key))) { | ||
throw new TypeError(`${context} has no property '${key}'`) | ||
if (Array.isArray(key)) { | ||
return key.map(query => getSingleKey(query, context)) | ||
} | ||
if (context === undefined) { | ||
throw new TypeError(`Context is undefined`) | ||
} | ||
if (typeof key === "object") { | ||
const output = {} | ||
if (key === undefined) { | ||
return context | ||
for (let [prop, query] of Object.entries(key)) { | ||
output[prop] = getSingleKey(query, context) | ||
} | ||
return output | ||
} | ||
return dotProp.get(context, String(key)) | ||
return getSingleKey(key, context) | ||
} | ||
} |
@@ -5,3 +5,4 @@ export { fnt } from "./fnt" | ||
export { get } from "./fn/get" | ||
export { guard } from "./fn/guard" | ||
export { list, listAnd, listOr } from "./fn/list" | ||
export { pipe } from "./fn/pipe" |
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
31432
17
119