Comparing version 0.1.0-stone-8 to 0.1.0-stone-9
@@ -184,2 +184,19 @@ 'use strict'; | ||
var slug = function (val, max, duplicate) { | ||
if (max === void 0) { max = 0; } | ||
if (duplicate === void 0) { duplicate = 0; } | ||
var newVal = val.trim(); | ||
// Make the string lowercase and nomalize or replace accented characters or swap ñ for n. | ||
newVal = newVal.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, ""); | ||
// only allow lowercase chars and numbers, replace spaces and dashes to single dash. | ||
newVal = newVal.replace(/[^a-z0-9 -]/g, '').replace(/\s+/g, '-').replace(/-+/g, '-'); | ||
if (Number(max) > 0) { | ||
newVal = newVal.slice(0, Number(max)); | ||
} | ||
if (Number(duplicate) > 0) { | ||
newVal = newVal + '-' + duplicate; | ||
} | ||
return newVal; | ||
}; | ||
exports.camelCase = camelCase; | ||
@@ -190,2 +207,3 @@ exports.capitalize = capitalize; | ||
exports.random = random; | ||
exports.slug = slug; | ||
exports.snakeCase = snakeCase; | ||
@@ -192,0 +210,0 @@ exports.uniqid = uniqid; |
@@ -180,2 +180,19 @@ /*! ***************************************************************************** | ||
export { camelCase, capitalize, kebabCase, pascalCase, random, snakeCase, uniqid, urlDecode, urlDecodeAsync, urlEncode, urlEncodeAsync }; | ||
var slug = function (val, max, duplicate) { | ||
if (max === void 0) { max = 0; } | ||
if (duplicate === void 0) { duplicate = 0; } | ||
var newVal = val.trim(); | ||
// Make the string lowercase and nomalize or replace accented characters or swap ñ for n. | ||
newVal = newVal.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, ""); | ||
// only allow lowercase chars and numbers, replace spaces and dashes to single dash. | ||
newVal = newVal.replace(/[^a-z0-9 -]/g, '').replace(/\s+/g, '-').replace(/-+/g, '-'); | ||
if (Number(max) > 0) { | ||
newVal = newVal.slice(0, Number(max)); | ||
} | ||
if (Number(duplicate) > 0) { | ||
newVal = newVal + '-' + duplicate; | ||
} | ||
return newVal; | ||
}; | ||
export { camelCase, capitalize, kebabCase, pascalCase, random, slug, snakeCase, uniqid, urlDecode, urlDecodeAsync, urlEncode, urlEncodeAsync }; |
@@ -15,2 +15,2 @@ var string=function(e){"use strict"; | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */function r(e,r,n,t){return new(n||(n=Promise))((function(a,o){function c(e){try{i(t.next(e))}catch(e){o(e)}}function l(e){try{i(t.throw(e))}catch(e){o(e)}}function i(e){var r;e.done?a(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(c,l)}i((t=t.apply(e,r||[])).next())}))}function n(e,r){var n,t,a,o,c={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function l(o){return function(l){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;c;)try{if(n=1,t&&(a=2&o[0]?t.return:o[0]?t.throw||((a=t.return)&&a.call(t),0):t.next)&&!(a=a.call(t,o[1])).done)return a;switch(t=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return c.label++,{value:o[1],done:!1};case 5:c.label++,t=o[1],o=[0];continue;case 7:o=c.ops.pop(),c.trys.pop();continue;default:if(!(a=c.trys,(a=a.length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){c=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){c.label=o[1];break}if(6===o[0]&&c.label<a[1]){c.label=a[1],a=o;break}if(a&&c.label<a[2]){c.label=a[2],c.ops.push(o);break}a[2]&&c.ops.pop(),c.trys.pop();continue}o=r.call(e,c)}catch(e){o=[6,e],t=0}finally{n=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,l])}}}var t=function(e,r){void 0===r&&(r="raw");var n=encodeURI(e);return"param"===r&&(n=encodeURIComponent(e)),n},a=function(e,r){void 0===r&&(r="raw");var n=decodeURI(e);return"param"===r&&(n=decodeURIComponent(e)),n},o=function(e,r){void 0===r&&(r="");var n=e;return n="multiple"===r?n.toLowerCase().replace(/\w\S*/g,(function(e){return e.replace(/^\w/,(function(e){return e.toUpperCase()}))})):"single"===r?n.toLowerCase().trimStart().replace(/^\w/,(function(e){return e.toUpperCase()})):n.trimStart().replace(/^\w/,(function(e){return e.toUpperCase()}))};return e.camelCase=function(e){var r=e.replace(/-|_/g," ").replace(/[A-Z]/g," $&");return(r=o(r,"multiple")).trimStart().replace(/^\w/,(function(e){return e.toLowerCase()})).replaceAll(" ","")},e.capitalize=o,e.kebabCase=function(e){var r=e.replace(/-|_/g," ").replace(/[A-Z]/g," $&");return(r=o(r,"multiple")).replaceAll(" ","").replace(/[A-Z]+(?![a-z])|[A-Z]/g,(function(e,r){return(r>0?"-":"")+e.toLowerCase()}))},e.pascalCase=function(e){var r=e.replace(/-|_/g," ").replace(/[A-Z]/g," $&");return(r=o(r,"multiple")).replaceAll(" ","")},e.random=function(e,r){void 0===e&&(e=11),void 0===r&&(r="");var n="",t="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_~!@#$%^&*()+={}[]|:;<>,./?";"alphadash"===r?t=t.slice(0,64):"alphanumeric"===r?t=t.slice(0,62):"alpha"===r?t=t.slice(10,62):"hex"===r?t=t.slice(0,16):"numeric"===r&&(t=t.slice(0,10));for(var a=0;a<e;a++)n+=t.charAt(Math.floor(Math.random()*t.length));return n},e.snakeCase=function(e){var r=e.replace(/-|_/g," ").replace(/[A-Z]/g," $&");return(r=o(r,"multiple")).replaceAll(" ","").replace(/[A-Z]+(?![a-z])|[A-Z]/g,(function(e,r){return(r>0?"_":"")+e.toLowerCase()}))},e.uniqid=function(e){void 0===e&&(e=0);var r="",n="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",t=String(Math.abs((new Date).valueOf()));Number(e)>=1&&(r+=String(Number(e)+1));for(var a=0;a<t.length;a++)r+=n.charAt(Math.floor(Math.random()*n.length)),r+=t.charAt(a);return r},e.urlDecode=a,e.urlDecodeAsync=function(e,t){return void 0===t&&(t="raw"),r(void 0,void 0,void 0,(function(){var r;return n(this,(function(n){switch(n.label){case 0:return[4,Promise.resolve(e)];case 1:return r=n.sent(),[2,Promise.resolve(a(r,t))]}}))}))},e.urlEncode=t,e.urlEncodeAsync=function(e,a){return void 0===a&&(a="raw"),r(void 0,void 0,void 0,(function(){var r;return n(this,(function(n){switch(n.label){case 0:return[4,Promise.resolve(e)];case 1:return r=n.sent(),[2,Promise.resolve(t(r,a))]}}))}))},Object.defineProperty(e,"__esModule",{value:!0}),e}({}); | ||
***************************************************************************** */function r(e,r,n,t){return new(n||(n=Promise))((function(a,o){function c(e){try{u(t.next(e))}catch(e){o(e)}}function l(e){try{u(t.throw(e))}catch(e){o(e)}}function u(e){var r;e.done?a(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(c,l)}u((t=t.apply(e,r||[])).next())}))}function n(e,r){var n,t,a,o,c={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function l(o){return function(l){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;c;)try{if(n=1,t&&(a=2&o[0]?t.return:o[0]?t.throw||((a=t.return)&&a.call(t),0):t.next)&&!(a=a.call(t,o[1])).done)return a;switch(t=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return c.label++,{value:o[1],done:!1};case 5:c.label++,t=o[1],o=[0];continue;case 7:o=c.ops.pop(),c.trys.pop();continue;default:if(!(a=c.trys,(a=a.length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){c=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){c.label=o[1];break}if(6===o[0]&&c.label<a[1]){c.label=a[1],a=o;break}if(a&&c.label<a[2]){c.label=a[2],c.ops.push(o);break}a[2]&&c.ops.pop(),c.trys.pop();continue}o=r.call(e,c)}catch(e){o=[6,e],t=0}finally{n=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,l])}}}var t=function(e,r){void 0===r&&(r="raw");var n=encodeURI(e);return"param"===r&&(n=encodeURIComponent(e)),n},a=function(e,r){void 0===r&&(r="raw");var n=decodeURI(e);return"param"===r&&(n=decodeURIComponent(e)),n},o=function(e,r){void 0===r&&(r="");var n=e;return n="multiple"===r?n.toLowerCase().replace(/\w\S*/g,(function(e){return e.replace(/^\w/,(function(e){return e.toUpperCase()}))})):"single"===r?n.toLowerCase().trimStart().replace(/^\w/,(function(e){return e.toUpperCase()})):n.trimStart().replace(/^\w/,(function(e){return e.toUpperCase()}))};return e.camelCase=function(e){var r=e.replace(/-|_/g," ").replace(/[A-Z]/g," $&");return(r=o(r,"multiple")).trimStart().replace(/^\w/,(function(e){return e.toLowerCase()})).replaceAll(" ","")},e.capitalize=o,e.kebabCase=function(e){var r=e.replace(/-|_/g," ").replace(/[A-Z]/g," $&");return(r=o(r,"multiple")).replaceAll(" ","").replace(/[A-Z]+(?![a-z])|[A-Z]/g,(function(e,r){return(r>0?"-":"")+e.toLowerCase()}))},e.pascalCase=function(e){var r=e.replace(/-|_/g," ").replace(/[A-Z]/g," $&");return(r=o(r,"multiple")).replaceAll(" ","")},e.random=function(e,r){void 0===e&&(e=11),void 0===r&&(r="");var n="",t="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_~!@#$%^&*()+={}[]|:;<>,./?";"alphadash"===r?t=t.slice(0,64):"alphanumeric"===r?t=t.slice(0,62):"alpha"===r?t=t.slice(10,62):"hex"===r?t=t.slice(0,16):"numeric"===r&&(t=t.slice(0,10));for(var a=0;a<e;a++)n+=t.charAt(Math.floor(Math.random()*t.length));return n},e.slug=function(e,r,n){void 0===r&&(r=0),void 0===n&&(n=0);var t=e.trim();return t=(t=t.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"")).replace(/[^a-z0-9 -]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-"),Number(r)>0&&(t=t.slice(0,Number(r))),Number(n)>0&&(t=t+"-"+n),t},e.snakeCase=function(e){var r=e.replace(/-|_/g," ").replace(/[A-Z]/g," $&");return(r=o(r,"multiple")).replaceAll(" ","").replace(/[A-Z]+(?![a-z])|[A-Z]/g,(function(e,r){return(r>0?"_":"")+e.toLowerCase()}))},e.uniqid=function(e){void 0===e&&(e=0);var r="",n="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",t=String(Math.abs((new Date).valueOf()));Number(e)>=1&&(r+=String(Number(e)+1));for(var a=0;a<t.length;a++)r+=n.charAt(Math.floor(Math.random()*n.length)),r+=t.charAt(a);return r},e.urlDecode=a,e.urlDecodeAsync=function(e,t){return void 0===t&&(t="raw"),r(void 0,void 0,void 0,(function(){var r;return n(this,(function(n){switch(n.label){case 0:return[4,Promise.resolve(e)];case 1:return r=n.sent(),[2,Promise.resolve(a(r,t))]}}))}))},e.urlEncode=t,e.urlEncodeAsync=function(e,a){return void 0===a&&(a="raw"),r(void 0,void 0,void 0,(function(){var r;return n(this,(function(n){switch(n.label){case 0:return[4,Promise.resolve(e)];case 1:return r=n.sent(),[2,Promise.resolve(t(r,a))]}}))}))},Object.defineProperty(e,"__esModule",{value:!0}),e}({}); |
{ | ||
"name": "alga-js", | ||
"version": "0.1.0-stone-8", | ||
"version": "0.1.0-stone-9", | ||
"description": "Alga.js is a JavaScript helper to help build UI components by using any of modern web frameworks or libraries", | ||
@@ -5,0 +5,0 @@ "module": "./dist/alga.min.js", |
@@ -6,1 +6,2 @@ export * from './urlString.js' | ||
export * from './caseString.js' | ||
export * from './slugString.js' |
@@ -6,1 +6,2 @@ export * from './urlString.js'; | ||
export * from './caseString.js'; | ||
export * from './slugString.js'; |
267198
171
3596