underscore-99xp
Advanced tools
Comparing version 1.8.0 to 1.8.1
@@ -324,2 +324,19 @@ import _ from 'underscore'; | ||
} | ||
}; // promise sequence | ||
_.promiseSequence = function (fns) { | ||
return new Promise(function (resolve, reject) { | ||
fns.reduce(function (p, fn) { | ||
return p.then(function (r) { | ||
return !_.size(r) || !(r[r.length - 1] instanceof Error) ? fn().then(Array.prototype.concat.bind(r))["catch"](Array.prototype.concat.bind(r)) : r; | ||
}); | ||
}, Promise.resolve([])).then(function (r) { | ||
if (r[r.length - 1] instanceof Error) { | ||
reject(r[r.length - 1]); | ||
} | ||
resolve(r); | ||
}); | ||
}); | ||
}; // Add all string helpers from [underscore.string](https://github.com/esamattis/underscore.string) library | ||
@@ -326,0 +343,0 @@ |
@@ -5,3 +5,3 @@ /** | ||
* ---------------------------------- | ||
* v1.7.4 | ||
* v1.8.0 | ||
* | ||
@@ -344,2 +344,19 @@ * Copyright (c)2021 Bruno Foggia, 99xp. | ||
} | ||
}; // promise sequence | ||
_.promiseSequence = function (fns) { | ||
return new Promise(function (resolve, reject) { | ||
fns.reduce(function (p, fn) { | ||
return p.then(function (r) { | ||
return !_.size(r) || !(r[r.length - 1] instanceof Error) ? fn().then(Array.prototype.concat.bind(r))["catch"](Array.prototype.concat.bind(r)) : r; | ||
}); | ||
}, Promise.resolve([])).then(function (r) { | ||
if (r[r.length - 1] instanceof Error) { | ||
reject(r[r.length - 1]); | ||
} | ||
resolve(r); | ||
}); | ||
}); | ||
}; // Add all string helpers from [underscore.string](https://github.com/esamattis/underscore.string) library | ||
@@ -346,0 +363,0 @@ |
@@ -5,3 +5,3 @@ /** | ||
* ---------------------------------- | ||
* v1.7.4 | ||
* v1.8.0 | ||
* | ||
@@ -13,3 +13,3 @@ * Copyright (c)2021 Bruno Foggia, 99xp. | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("underscore"),require("underscore.string")):"function"==typeof define&&define.amd?define(["exports","underscore","underscore.string"],t):t((e=e||self)._x={},e._,e._s)}(this,function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}t=t&&t.hasOwnProperty("default")?t.default:t,r=r&&r.hasOwnProperty("default")?r.default:r,t.templateSettings={interpolate:/\{\{(.+?)\}\}/g,evaluate:/\{\%(.+?)\%\}/g,escape:/\{-([\s\S]+?)-\}/g},t.result2=function(e,r,n,i,a){var s;if(e&&t.isObject(e)&&(i||a)&&"function"==typeof e[r]){var o=e[r];a&&(o=t.bind(o,a)),i&&(o=t.partial(t.partial,o).apply(null,i)),s=o()||n}else s=t.result(e,r,n);return s},t.defaults2=function(e,r){var n=[],i=[],a=[],s=[];t.map(e,function(e,a){return(t.isJSON(e)||t.isArray(e))&&(t.isJSON(r[a])||t.isArray(r[a]))?i.push(a):n.push(a)}),t.map(r,function(r,n){return(t.isJSON(r)||t.isArray(r))&&(t.isJSON(e[n])||t.isArray(e[n]))?s.push(n):a.push(n)});var o=t.partial(t.pick,e).apply(null,n),u=t.partial(t.pick,e).apply(null,i),l=t.partial(t.pick,r).apply(null,a),p=t.partial(t.pick,r).apply(null,s);o=t.defaults(o,l);var f=[],c=t.clone(u);return t.size(p)&&t.map(p,function(e,r){if(-1===t.indexOf(f,r)){f.push(r);var n=t.isArray(p[r])?[]:{},i=t.defaults2(u[r]||n,p[r]);c[r]=t.isArray(n)?t.toArray(i):i}}),t.size(u)&&t.map(u,function(e,r){if(-1===t.indexOf(f,r)){f.push(r);var n=t.isArray(u[r])?[]:{},i=t.defaults2(u[r],p[r]||n);c[r]=t.isArray(n)?t.toArray(i):i}}),o=t.extend(o,c)},t.deepValueSearch=function(e,r){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i="string"==typeof e&&e?e.split(/\[/):e instanceof Array?e:[];if(!i.length)return r;var a=i.shift();if(/^(\w|\_|\-)+$/.test(a))return this.deepValueSearch(i,r[a],n);if("]"===a){if(!i.length)return r;if(r instanceof Array||t.isJSON(r)){var s=t.isJSON(r)||n?{}:[];for(var o in r)t.isJSON(s)?s[o]=this.deepValueSearch(t.clone(i),t.clone(r[o]),n):s.push(this.deepValueSearch(t.clone(i),t.clone(r[o]),n));return s}}return/(\w|\_|\-)+\]$/.test(a)?(a=a.replace("]",""),i.length?r?this.deepValueSearch(i,r[a],n):r:r?r[a]:void 0):void 0};var i=function e(t,r){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(r&&"object"===n(r))for(var a in r){var s=t+"["+a+"]";"object"===n(r[a])?e(s,r[a],i):i[s]=r[a]}else i[t]=r;return i};t.jsonToHTMLForm=function(e){if(!t.isJSON(e))return!1;var r={};if(t.size(e))for(var n in e)r=i(n,e[n],r);return r},t.deepKeySearch=function(e,r){var n=t.jsonToHTMLForm(r),i=[];return n&&(i=t.filter(t.keys(n),function(t){return new RegExp("^"+e.replace(/\[\]/,"[\\d+]").replace(/(\[|\])/g,"\\$1"),"g").test(t)})),i},t.isOnlyObject=function(e){return t.isObject(e)&&!t.isArray(e)},t.isJSON=function(e){return t.isOnlyObject(e)&&null===e.__proto__.__proto__},t.matchAll=function(e,t){var r=[];return e.replace(t,function(){var e=[].slice.call(arguments,0),t=e.splice(-2);e.index=t[0],e.input=t[1],r.push(e)}),r.length?r:null},t.regexIndexOf=function(e,t,r){var n=e.substring(r||0).search(t);return n>=0?n+(r||0):n},t.regexLastIndexOf=function(e,t,r){t=t.global?t:new RegExp(t.source,"g"+(t.ignoreCase?"i":"")+(t.multiLine?"m":"")),void 0===r?r=e.length:r<0&&(r=0);for(var n,i=e.substring(0,r+1),a=-1,s=0;null!=(n=t.exec(i));)a=n.index,t.lastIndex=++s;return a},t.toDate=function(e){if(!/^\d{4}\-\d{2}/.test(e))return!1;var r=e.toString().split(t.regexIndexOf(e.toString(),/T/)>0?"T":" "),n=r[0].split("-"),i=r[1]?r[1].split(":"):[0,0,0];return new Date(n[0],parseInt(n[1]||0,10)-1,parseInt(n[2]||1,10),i[0]||0,i[1]||0,i[2]||0)},t.defaultPorts={http:80,https:443,ftp:21},t.parseUrl=function(e){var r=/^((http[s]?|ftp):\/)?\/?([^:\/\s]+)(:([^\/]*))?(((\/\w+)*\/)([\w\-\.]+[^#?\s]+)(\?([^#]*))?(#(.*))?)$/gm.exec(e);if(r)return{schema:r[2],hostname:r[3],port:r[5]||t.defaultPorts[r[2]],path:r[6]||""}},t.mixin(r.exports()),e.default=t,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("underscore"),require("underscore.string")):"function"==typeof define&&define.amd?define(["exports","underscore","underscore.string"],t):t((e=e||self)._x={},e._,e._s)}(this,function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}t=t&&t.hasOwnProperty("default")?t.default:t,r=r&&r.hasOwnProperty("default")?r.default:r,t.templateSettings={interpolate:/\{\{(.+?)\}\}/g,evaluate:/\{\%(.+?)\%\}/g,escape:/\{-([\s\S]+?)-\}/g},t.result2=function(e,r,n,i,o){var a;if(e&&t.isObject(e)&&(i||o)&&"function"==typeof e[r]){var u=e[r];o&&(u=t.bind(u,o)),i&&(u=t.partial(t.partial,u).apply(null,i)),a=u()||n}else a=t.result(e,r,n);return a},t.defaults2=function(e,r){var n=[],i=[],o=[],a=[];t.map(e,function(e,o){return(t.isJSON(e)||t.isArray(e))&&(t.isJSON(r[o])||t.isArray(r[o]))?i.push(o):n.push(o)}),t.map(r,function(r,n){return(t.isJSON(r)||t.isArray(r))&&(t.isJSON(e[n])||t.isArray(e[n]))?a.push(n):o.push(n)});var u=t.partial(t.pick,e).apply(null,n),s=t.partial(t.pick,e).apply(null,i),l=t.partial(t.pick,r).apply(null,o),f=t.partial(t.pick,r).apply(null,a);u=t.defaults(u,l);var c=[],p=t.clone(s);return t.size(f)&&t.map(f,function(e,r){if(-1===t.indexOf(c,r)){c.push(r);var n=t.isArray(f[r])?[]:{},i=t.defaults2(s[r]||n,f[r]);p[r]=t.isArray(n)?t.toArray(i):i}}),t.size(s)&&t.map(s,function(e,r){if(-1===t.indexOf(c,r)){c.push(r);var n=t.isArray(s[r])?[]:{},i=t.defaults2(s[r],f[r]||n);p[r]=t.isArray(n)?t.toArray(i):i}}),u=t.extend(u,p)},t.deepValueSearch=function(e,r){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i="string"==typeof e&&e?e.split(/\[/):e instanceof Array?e:[];if(!i.length)return r;var o=i.shift();if(/^(\w|\_|\-)+$/.test(o))return this.deepValueSearch(i,r[o],n);if("]"===o){if(!i.length)return r;if(r instanceof Array||t.isJSON(r)){var a=t.isJSON(r)||n?{}:[];for(var u in r)t.isJSON(a)?a[u]=this.deepValueSearch(t.clone(i),t.clone(r[u]),n):a.push(this.deepValueSearch(t.clone(i),t.clone(r[u]),n));return a}}return/(\w|\_|\-)+\]$/.test(o)?(o=o.replace("]",""),i.length?r?this.deepValueSearch(i,r[o],n):r:r?r[o]:void 0):void 0};var i=function e(t,r){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(r&&"object"===n(r))for(var o in r){var a=t+"["+o+"]";"object"===n(r[o])?e(a,r[o],i):i[a]=r[o]}else i[t]=r;return i};t.jsonToHTMLForm=function(e){if(!t.isJSON(e))return!1;var r={};if(t.size(e))for(var n in e)r=i(n,e[n],r);return r},t.deepKeySearch=function(e,r){var n=t.jsonToHTMLForm(r),i=[];return n&&(i=t.filter(t.keys(n),function(t){return new RegExp("^"+e.replace(/\[\]/,"[\\d+]").replace(/(\[|\])/g,"\\$1"),"g").test(t)})),i},t.isOnlyObject=function(e){return t.isObject(e)&&!t.isArray(e)},t.isJSON=function(e){return t.isOnlyObject(e)&&null===e.__proto__.__proto__},t.matchAll=function(e,t){var r=[];return e.replace(t,function(){var e=[].slice.call(arguments,0),t=e.splice(-2);e.index=t[0],e.input=t[1],r.push(e)}),r.length?r:null},t.regexIndexOf=function(e,t,r){var n=e.substring(r||0).search(t);return n>=0?n+(r||0):n},t.regexLastIndexOf=function(e,t,r){t=t.global?t:new RegExp(t.source,"g"+(t.ignoreCase?"i":"")+(t.multiLine?"m":"")),void 0===r?r=e.length:r<0&&(r=0);for(var n,i=e.substring(0,r+1),o=-1,a=0;null!=(n=t.exec(i));)o=n.index,t.lastIndex=++a;return o},t.toDate=function(e){if(!/^\d{4}\-\d{2}/.test(e))return!1;var r=e.toString().split(t.regexIndexOf(e.toString(),/T/)>0?"T":" "),n=r[0].split("-"),i=r[1]?r[1].split(":"):[0,0,0];return new Date(n[0],parseInt(n[1]||0,10)-1,parseInt(n[2]||1,10),i[0]||0,i[1]||0,i[2]||0)},t.defaultPorts={http:80,https:443,ftp:21},t.parseUrl=function(e){var r=/^((http[s]?|ftp):\/)?\/?([^:\/\s]+)(:([^\/]*))?(((\/\w+)*\/)([\w\-\.]+[^#?\s]+)(\?([^#]*))?(#(.*))?)$/gm.exec(e);if(r)return{schema:r[2],hostname:r[3],port:r[5]||t.defaultPorts[r[2]],path:r[6]||""}},t.promiseSequence=function(e){return new Promise(function(r,n){e.reduce(function(e,r){return e.then(function(e){return t.size(e)&&e[e.length-1]instanceof Error?e:r().then(Array.prototype.concat.bind(e)).catch(Array.prototype.concat.bind(e))})},Promise.resolve([])).then(function(e){e[e.length-1]instanceof Error&&n(e[e.length-1]),r(e)})})},t.mixin(r.exports()),e.default=t,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=underscore-99xp.min.js.map |
{ | ||
"name": "underscore-99xp", | ||
"version": "1.8.0", | ||
"version": "1.8.1", | ||
"keywords": [ | ||
@@ -5,0 +5,0 @@ "util", |
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
669498
1790