Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

inflected

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

inflected - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

src/constantify.js

6

dist/esm/inflected.js

@@ -556,2 +556,6 @@ var toString = Object.prototype.toString;

export { pluralize, singularize, camelize, underscore, humanize, titleize, tableize, classify, dasherize, foreignKey, ordinal, ordinalize, transliterate, parameterize, capitalize, inflections, transliterations };
function constantify(word) {
return underscore(word).toUpperCase().replace(/\s+/g, "_");
}
export { pluralize, singularize, camelize, underscore, humanize, titleize, tableize, classify, dasherize, foreignKey, ordinal, ordinalize, transliterate, parameterize, capitalize, inflections, transliterations, constantify };

@@ -562,2 +562,6 @@ (function (global, factory) {

function constantify(word) {
return underscore(word).toUpperCase().replace(/\s+/g, "_");
}
exports.pluralize = pluralize;

@@ -580,2 +584,3 @@ exports.singularize = singularize;

exports.transliterations = transliterations;
exports.constantify = constantify;

@@ -582,0 +587,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

2

dist/umd/inflected.min.js

@@ -1,1 +0,1 @@

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(e.Inflector=e.Inflector||{})}(this,function(e){"use strict";function r(e){return"[object Function]"===z.call(e)}function n(e){return e.split("").map(function(e){return"(?:"+e.toUpperCase()+"|"+e.toLowerCase()+")"}).join("")}function i(e,r){for(var n=e.length-1;n>=0;n--)e[n]===r&&Array.prototype.splice.call(e,n,1)}function a(e,r){return Object.prototype.hasOwnProperty.call(e,r)}function t(e){e.plural(/$/,"s"),e.plural(/s$/i,"s"),e.plural(/^(ax|test)is$/i,"$1es"),e.plural(/(octop|vir)us$/i,"$1i"),e.plural(/(octop|vir)i$/i,"$1i"),e.plural(/(alias|status)$/i,"$1es"),e.plural(/(bu)s$/i,"$1ses"),e.plural(/(buffal|tomat)o$/i,"$1oes"),e.plural(/([ti])um$/i,"$1a"),e.plural(/([ti])a$/i,"$1a"),e.plural(/sis$/i,"ses"),e.plural(/(?:([^f])fe|([lr])f)$/i,"$1$2ves"),e.plural(/(hive)$/i,"$1s"),e.plural(/([^aeiouy]|qu)y$/i,"$1ies"),e.plural(/(x|ch|ss|sh)$/i,"$1es"),e.plural(/(matr|vert|ind)(?:ix|ex)$/i,"$1ices"),e.plural(/^(m|l)ouse$/i,"$1ice"),e.plural(/^(m|l)ice$/i,"$1ice"),e.plural(/^(ox)$/i,"$1en"),e.plural(/^(oxen)$/i,"$1"),e.plural(/(quiz)$/i,"$1zes"),e.singular(/s$/i,""),e.singular(/(ss)$/i,"$1"),e.singular(/(n)ews$/i,"$1ews"),e.singular(/([ti])a$/i,"$1um"),e.singular(/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)$/i,"$1sis"),e.singular(/(^analy)(sis|ses)$/i,"$1sis"),e.singular(/([^f])ves$/i,"$1fe"),e.singular(/(hive)s$/i,"$1"),e.singular(/(tive)s$/i,"$1"),e.singular(/([lr])ves$/i,"$1f"),e.singular(/([^aeiouy]|qu)ies$/i,"$1y"),e.singular(/(s)eries$/i,"$1eries"),e.singular(/(m)ovies$/i,"$1ovie"),e.singular(/(x|ch|ss|sh)es$/i,"$1"),e.singular(/^(m|l)ice$/i,"$1ouse"),e.singular(/(bus)(es)?$/i,"$1"),e.singular(/(o)es$/i,"$1"),e.singular(/(shoe)s$/i,"$1"),e.singular(/(cris|test)(is|es)$/i,"$1is"),e.singular(/^(a)x[ie]s$/i,"$1xis"),e.singular(/(octop|vir)(us|i)$/i,"$1us"),e.singular(/(alias|status)(es)?$/i,"$1"),e.singular(/^(ox)en/i,"$1"),e.singular(/(vert|ind)ices$/i,"$1ex"),e.singular(/(matr)ices$/i,"$1ix"),e.singular(/(quiz)zes$/i,"$1"),e.singular(/(database)s$/i,"$1"),e.irregular("person","people"),e.irregular("man","men"),e.irregular("child","children"),e.irregular("sex","sexes"),e.irregular("move","moves"),e.irregular("zombie","zombies"),e.uncountable("equipment","information","rice","money","species","series","fish","sheep","jeans","police")}function s(e,n){if(r(e)&&(n=e,e=null),e=e||"en",!n)return L.getInstance(e);n(L.getInstance(e))}function u(e,r){var n,i,a,t=""+e;if(0===t.length)return t;var u=t.toLowerCase().match(/\b\w+$/);if(u&&s().uncountables.indexOf(u[0])>-1)return t;for(var o=0,l=r.length;o<l;o++)if(n=r[o],i=n[0],a=n[1],t.match(i)){t=t.replace(i,a);break}return t}function o(e){return u(e,s(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en").plurals)}function l(e){return u(e,s(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en").singulars)}function c(e){var r=null===e||void 0===e?"":String(e);return r.charAt(0).toUpperCase()+r.slice(1)}function p(e,r){null!==r&&void 0!==r||(r=!0);var n=""+e;return n=r?n.replace(/^[a-z\d]*/,function(e){return s().acronyms[e]||c(e)}):n.replace(new RegExp("^(?:"+s().acronymRegex.source+"(?=\\b|[A-Z_])|\\w)"),function(e){return e.toLowerCase()}),n=n.replace(/(?:_|(\/))([a-z\d]*)/gi,function(e,r,n,i,a){return r||(r=""),""+r+(s().acronyms[n]||c(n))})}function $(e){var r=""+e;return r=r.replace(new RegExp("(?:([A-Za-z\\d])|^)("+s().acronymRegex.source+")(?=\\b|[^a-z])","g"),function(e,r,n){return(r||"")+(r?"_":"")+n.toLowerCase()}),r=r.replace(/([A-Z\d]+)([A-Z][a-z])/g,"$1_$2"),r=r.replace(/([a-z\d])([A-Z])/g,"$1_$2"),r=r.replace(/-/g,"_"),r.toLowerCase()}function g(e,r){var n=""+e,i=s().humans,a=void 0,t=void 0,u=void 0;r=r||{},null!==r.capitalize&&void 0!==r.capitalize||(r.capitalize=!0);for(var o=0,l=i.length;o<l;o++)if(a=i[o],t=a[0],u=a[1],t.test&&t.test(n)||n.indexOf(t)>-1){n=n.replace(t,u);break}return n=n.replace(/_id$/,""),n=n.replace(/_/g," "),n=n.replace(/([a-z\d]*)/gi,function(e){return s().acronyms[e]||e.toLowerCase()}),r.capitalize&&(n=n.replace(/^\w/,function(e){return e.toUpperCase()})),n}function f(e){return g($(e)).replace(/(^|[\s¿\/]+)([a-z])/g,function(e,r,n,i,a){return e.replace(n,n.toUpperCase())})}function h(e){return o($(e))}function v(e){return p(l(e.replace(/.*\./g,"")))}function m(e){return e.replace(/_/g,"-")}function y(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return $(e)+(r?"_id":"id")}function d(e){var r=Math.abs(Number(e)),n=r%100;if(11===n||12===n||13===n)return"th";switch(r%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}}function w(e){return""+e+d(e)}function x(e,n){if(r(e)&&(n=e,e=null),e=e||"en",!n)return _.getInstance(e);n(_.getInstance(e))}function b(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.locale||"en",i=r.replacement||"?";return x(n).transliterate(e,i)}function C(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};void 0===r.separator&&(r.separator="-"),null===r.separator&&(r.separator="");var n=b(e,r);if(n=n.replace(/[^a-z0-9\-_]+/gi,r.separator),r.separator.length){var i=new RegExp(r.separator);n=n.replace(new RegExp(i.source+"{2,}"),r.separator),n=n.replace(new RegExp("^"+i.source+"|"+i.source+"$","i"),"")}return n.toLowerCase()}var z=Object.prototype.toString,E=function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")},R=function(){function e(e,r){for(var n=0;n<r.length;n++){var i=r[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(r,n,i){return n&&e(r.prototype,n),i&&e(r,i),r}}(),U={},L=function(){function e(){E(this,e),this.plurals=[],this.singulars=[],this.uncountables=[],this.humans=[],this.acronyms={},this.acronymRegex=/(?=a)b/}return R(e,null,[{key:"getInstance",value:function(r){return U[r]=U[r]||new e,U[r]}}]),R(e,[{key:"acronym",value:function(e){this.acronyms[e.toLowerCase()]=e;var r=[];for(var n in this.acronyms)a(this.acronyms,n)&&r.push(this.acronyms[n]);this.acronymRegex=new RegExp(r.join("|"))}},{key:"plural",value:function(e,r){"string"==typeof e&&i(this.uncountables,e),i(this.uncountables,r),this.plurals.unshift([e,r])}},{key:"singular",value:function(e,r){"string"==typeof e&&i(this.uncountables,e),i(this.uncountables,r),this.singulars.unshift([e,r])}},{key:"irregular",value:function(e,r){i(this.uncountables,e),i(this.uncountables,r);var a=e[0],t=e.substr(1),s=r[0],u=r.substr(1);if(a.toUpperCase()===s.toUpperCase())this.plural(new RegExp("("+a+")"+t+"$","i"),"$1"+u),this.plural(new RegExp("("+s+")"+u+"$","i"),"$1"+u),this.singular(new RegExp("("+a+")"+t+"$","i"),"$1"+t),this.singular(new RegExp("("+s+")"+u+"$","i"),"$1"+t);else{var o=n(t),l=n(u);this.plural(new RegExp(a.toUpperCase()+o+"$"),s.toUpperCase()+u),this.plural(new RegExp(a.toLowerCase()+o+"$"),s.toLowerCase()+u),this.plural(new RegExp(s.toUpperCase()+l+"$"),s.toUpperCase()+u),this.plural(new RegExp(s.toLowerCase()+l+"$"),s.toLowerCase()+u),this.singular(new RegExp(a.toUpperCase()+o+"$"),a.toUpperCase()+t),this.singular(new RegExp(a.toLowerCase()+o+"$"),a.toLowerCase()+t),this.singular(new RegExp(s.toUpperCase()+l+"$"),a.toUpperCase()+t),this.singular(new RegExp(s.toLowerCase()+l+"$"),a.toLowerCase()+t)}}},{key:"uncountable",value:function(){for(var e=arguments.length,r=Array(e),n=0;n<e;n++)r[n]=arguments[n];this.uncountables=this.uncountables.concat(r)}},{key:"human",value:function(e,r){this.humans.unshift([e,r])}},{key:"clear",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"all";"all"===e?(this.plurals=[],this.singulars=[],this.uncountables=[],this.humans=[]):this[e]=[]}}]),e}(),A={en:t};for(var I in A)s(I,A[I]);var O={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","Æ":"AE","Ç":"C","È":"E","É":"E","Ê":"E","Ë":"E","Ì":"I","Í":"I","Î":"I","Ï":"I","Ð":"D","Ñ":"N","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","×":"x","Ø":"O","Ù":"U","Ú":"U","Û":"U","Ü":"U","Ý":"Y","Þ":"Th","ß":"ss","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","æ":"ae","ç":"c","è":"e","é":"e","ê":"e","ë":"e","ì":"i","í":"i","î":"i","ï":"i","ð":"d","ñ":"n","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","ù":"u","ú":"u","û":"u","ü":"u","ý":"y","þ":"th","ÿ":"y","Ā":"A","ā":"a","Ă":"A","ă":"a","Ą":"A","ą":"a","Ć":"C","ć":"c","Ĉ":"C","ĉ":"c","Ċ":"C","ċ":"c","Č":"C","č":"c","Ď":"D","ď":"d","Đ":"D","đ":"d","Ē":"E","ē":"e","Ĕ":"E","ĕ":"e","Ė":"E","ė":"e","Ę":"E","ę":"e","Ě":"E","ě":"e","Ĝ":"G","ĝ":"g","Ğ":"G","ğ":"g","Ġ":"G","ġ":"g","Ģ":"G","ģ":"g","Ĥ":"H","ĥ":"h","Ħ":"H","ħ":"h","Ĩ":"I","ĩ":"i","Ī":"I","ī":"i","Ĭ":"I","ĭ":"i","Į":"I","į":"i","İ":"I","ı":"i","IJ":"IJ","ij":"ij","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","ĺ":"l","Ļ":"L","ļ":"l","Ľ":"L","ľ":"l","Ŀ":"L","ŀ":"l","Ł":"L","ł":"l","Ń":"N","ń":"n","Ņ":"N","ņ":"n","Ň":"N","ň":"n","ʼn":"'n","Ŋ":"NG","ŋ":"ng","Ō":"O","ō":"o","Ŏ":"O","ŏ":"o","Ő":"O","ő":"o","Œ":"OE","œ":"oe","Ŕ":"R","ŕ":"r","Ŗ":"R","ŗ":"r","Ř":"R","ř":"r","Ś":"S","ś":"s","Ŝ":"S","ŝ":"s","Ş":"S","ş":"s","Š":"S","š":"s","Ţ":"T","ţ":"t","Ť":"T","ť":"t","Ŧ":"T","ŧ":"t","Ũ":"U","ũ":"u","Ū":"U","ū":"u","Ŭ":"U","ŭ":"u","Ů":"U","ů":"u","Ű":"U","ű":"u","Ų":"U","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","ź":"z","Ż":"Z","ż":"z","Ž":"Z","ž":"z"},k={},_=function(){function e(){E(this,e),this.approximations={};for(var r in O)this.approximate(r,O[r])}return R(e,null,[{key:"getInstance",value:function(r){return k[r]=k[r]||new e,k[r]}}]),R(e,[{key:"approximate",value:function(e,r){this.approximations[e]=r}},{key:"transliterate",value:function(e,r){var n=this;return e.replace(/[^\u0000-\u007f]/g,function(e){return n.approximations[e]||r||"?"})}}]),e}();e.pluralize=o,e.singularize=l,e.camelize=p,e.underscore=$,e.humanize=g,e.titleize=f,e.tableize=h,e.classify=v,e.dasherize=m,e.foreignKey=y,e.ordinal=d,e.ordinalize=w,e.transliterate=b,e.parameterize=C,e.capitalize=c,e.inflections=s,e.transliterations=x,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(e.Inflector=e.Inflector||{})}(this,function(e){"use strict";function r(e){return"[object Function]"===E.call(e)}function n(e){return e.split("").map(function(e){return"(?:"+e.toUpperCase()+"|"+e.toLowerCase()+")"}).join("")}function i(e,r){for(var n=e.length-1;n>=0;n--)e[n]===r&&Array.prototype.splice.call(e,n,1)}function a(e,r){return Object.prototype.hasOwnProperty.call(e,r)}function t(e){e.plural(/$/,"s"),e.plural(/s$/i,"s"),e.plural(/^(ax|test)is$/i,"$1es"),e.plural(/(octop|vir)us$/i,"$1i"),e.plural(/(octop|vir)i$/i,"$1i"),e.plural(/(alias|status)$/i,"$1es"),e.plural(/(bu)s$/i,"$1ses"),e.plural(/(buffal|tomat)o$/i,"$1oes"),e.plural(/([ti])um$/i,"$1a"),e.plural(/([ti])a$/i,"$1a"),e.plural(/sis$/i,"ses"),e.plural(/(?:([^f])fe|([lr])f)$/i,"$1$2ves"),e.plural(/(hive)$/i,"$1s"),e.plural(/([^aeiouy]|qu)y$/i,"$1ies"),e.plural(/(x|ch|ss|sh)$/i,"$1es"),e.plural(/(matr|vert|ind)(?:ix|ex)$/i,"$1ices"),e.plural(/^(m|l)ouse$/i,"$1ice"),e.plural(/^(m|l)ice$/i,"$1ice"),e.plural(/^(ox)$/i,"$1en"),e.plural(/^(oxen)$/i,"$1"),e.plural(/(quiz)$/i,"$1zes"),e.singular(/s$/i,""),e.singular(/(ss)$/i,"$1"),e.singular(/(n)ews$/i,"$1ews"),e.singular(/([ti])a$/i,"$1um"),e.singular(/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)$/i,"$1sis"),e.singular(/(^analy)(sis|ses)$/i,"$1sis"),e.singular(/([^f])ves$/i,"$1fe"),e.singular(/(hive)s$/i,"$1"),e.singular(/(tive)s$/i,"$1"),e.singular(/([lr])ves$/i,"$1f"),e.singular(/([^aeiouy]|qu)ies$/i,"$1y"),e.singular(/(s)eries$/i,"$1eries"),e.singular(/(m)ovies$/i,"$1ovie"),e.singular(/(x|ch|ss|sh)es$/i,"$1"),e.singular(/^(m|l)ice$/i,"$1ouse"),e.singular(/(bus)(es)?$/i,"$1"),e.singular(/(o)es$/i,"$1"),e.singular(/(shoe)s$/i,"$1"),e.singular(/(cris|test)(is|es)$/i,"$1is"),e.singular(/^(a)x[ie]s$/i,"$1xis"),e.singular(/(octop|vir)(us|i)$/i,"$1us"),e.singular(/(alias|status)(es)?$/i,"$1"),e.singular(/^(ox)en/i,"$1"),e.singular(/(vert|ind)ices$/i,"$1ex"),e.singular(/(matr)ices$/i,"$1ix"),e.singular(/(quiz)zes$/i,"$1"),e.singular(/(database)s$/i,"$1"),e.irregular("person","people"),e.irregular("man","men"),e.irregular("child","children"),e.irregular("sex","sexes"),e.irregular("move","moves"),e.irregular("zombie","zombies"),e.uncountable("equipment","information","rice","money","species","series","fish","sheep","jeans","police")}function s(e,n){if(r(e)&&(n=e,e=null),e=e||"en",!n)return A.getInstance(e);n(A.getInstance(e))}function u(e,r){var n,i,a,t=""+e;if(0===t.length)return t;var u=t.toLowerCase().match(/\b\w+$/);if(u&&s().uncountables.indexOf(u[0])>-1)return t;for(var o=0,l=r.length;o<l;o++)if(n=r[o],i=n[0],a=n[1],t.match(i)){t=t.replace(i,a);break}return t}function o(e){return u(e,s(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en").plurals)}function l(e){return u(e,s(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en").singulars)}function c(e){var r=null===e||void 0===e?"":String(e);return r.charAt(0).toUpperCase()+r.slice(1)}function p(e,r){null!==r&&void 0!==r||(r=!0);var n=""+e;return n=r?n.replace(/^[a-z\d]*/,function(e){return s().acronyms[e]||c(e)}):n.replace(new RegExp("^(?:"+s().acronymRegex.source+"(?=\\b|[A-Z_])|\\w)"),function(e){return e.toLowerCase()}),n=n.replace(/(?:_|(\/))([a-z\d]*)/gi,function(e,r,n,i,a){return r||(r=""),""+r+(s().acronyms[n]||c(n))})}function $(e){var r=""+e;return r=r.replace(new RegExp("(?:([A-Za-z\\d])|^)("+s().acronymRegex.source+")(?=\\b|[^a-z])","g"),function(e,r,n){return(r||"")+(r?"_":"")+n.toLowerCase()}),r=r.replace(/([A-Z\d]+)([A-Z][a-z])/g,"$1_$2"),r=r.replace(/([a-z\d])([A-Z])/g,"$1_$2"),r=r.replace(/-/g,"_"),r.toLowerCase()}function g(e,r){var n=""+e,i=s().humans,a=void 0,t=void 0,u=void 0;r=r||{},null!==r.capitalize&&void 0!==r.capitalize||(r.capitalize=!0);for(var o=0,l=i.length;o<l;o++)if(a=i[o],t=a[0],u=a[1],t.test&&t.test(n)||n.indexOf(t)>-1){n=n.replace(t,u);break}return n=n.replace(/_id$/,""),n=n.replace(/_/g," "),n=n.replace(/([a-z\d]*)/gi,function(e){return s().acronyms[e]||e.toLowerCase()}),r.capitalize&&(n=n.replace(/^\w/,function(e){return e.toUpperCase()})),n}function f(e){return g($(e)).replace(/(^|[\s¿\/]+)([a-z])/g,function(e,r,n,i,a){return e.replace(n,n.toUpperCase())})}function h(e){return o($(e))}function v(e){return p(l(e.replace(/.*\./g,"")))}function y(e){return e.replace(/_/g,"-")}function m(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return $(e)+(r?"_id":"id")}function d(e){var r=Math.abs(Number(e)),n=r%100;if(11===n||12===n||13===n)return"th";switch(r%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}}function w(e){return""+e+d(e)}function x(e,n){if(r(e)&&(n=e,e=null),e=e||"en",!n)return j.getInstance(e);n(j.getInstance(e))}function b(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.locale||"en",i=r.replacement||"?";return x(n).transliterate(e,i)}function C(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};void 0===r.separator&&(r.separator="-"),null===r.separator&&(r.separator="");var n=b(e,r);if(n=n.replace(/[^a-z0-9\-_]+/gi,r.separator),r.separator.length){var i=new RegExp(r.separator);n=n.replace(new RegExp(i.source+"{2,}"),r.separator),n=n.replace(new RegExp("^"+i.source+"|"+i.source+"$","i"),"")}return n.toLowerCase()}function z(e){return $(e).toUpperCase().replace(/\s+/g,"_")}var E=Object.prototype.toString,R=function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")},U=function(){function e(e,r){for(var n=0;n<r.length;n++){var i=r[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(r,n,i){return n&&e(r.prototype,n),i&&e(r,i),r}}(),L={},A=function(){function e(){R(this,e),this.plurals=[],this.singulars=[],this.uncountables=[],this.humans=[],this.acronyms={},this.acronymRegex=/(?=a)b/}return U(e,null,[{key:"getInstance",value:function(r){return L[r]=L[r]||new e,L[r]}}]),U(e,[{key:"acronym",value:function(e){this.acronyms[e.toLowerCase()]=e;var r=[];for(var n in this.acronyms)a(this.acronyms,n)&&r.push(this.acronyms[n]);this.acronymRegex=new RegExp(r.join("|"))}},{key:"plural",value:function(e,r){"string"==typeof e&&i(this.uncountables,e),i(this.uncountables,r),this.plurals.unshift([e,r])}},{key:"singular",value:function(e,r){"string"==typeof e&&i(this.uncountables,e),i(this.uncountables,r),this.singulars.unshift([e,r])}},{key:"irregular",value:function(e,r){i(this.uncountables,e),i(this.uncountables,r);var a=e[0],t=e.substr(1),s=r[0],u=r.substr(1);if(a.toUpperCase()===s.toUpperCase())this.plural(new RegExp("("+a+")"+t+"$","i"),"$1"+u),this.plural(new RegExp("("+s+")"+u+"$","i"),"$1"+u),this.singular(new RegExp("("+a+")"+t+"$","i"),"$1"+t),this.singular(new RegExp("("+s+")"+u+"$","i"),"$1"+t);else{var o=n(t),l=n(u);this.plural(new RegExp(a.toUpperCase()+o+"$"),s.toUpperCase()+u),this.plural(new RegExp(a.toLowerCase()+o+"$"),s.toLowerCase()+u),this.plural(new RegExp(s.toUpperCase()+l+"$"),s.toUpperCase()+u),this.plural(new RegExp(s.toLowerCase()+l+"$"),s.toLowerCase()+u),this.singular(new RegExp(a.toUpperCase()+o+"$"),a.toUpperCase()+t),this.singular(new RegExp(a.toLowerCase()+o+"$"),a.toLowerCase()+t),this.singular(new RegExp(s.toUpperCase()+l+"$"),a.toUpperCase()+t),this.singular(new RegExp(s.toLowerCase()+l+"$"),a.toLowerCase()+t)}}},{key:"uncountable",value:function(){for(var e=arguments.length,r=Array(e),n=0;n<e;n++)r[n]=arguments[n];this.uncountables=this.uncountables.concat(r)}},{key:"human",value:function(e,r){this.humans.unshift([e,r])}},{key:"clear",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"all";"all"===e?(this.plurals=[],this.singulars=[],this.uncountables=[],this.humans=[]):this[e]=[]}}]),e}(),I={en:t};for(var O in I)s(O,I[O]);var k={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","Æ":"AE","Ç":"C","È":"E","É":"E","Ê":"E","Ë":"E","Ì":"I","Í":"I","Î":"I","Ï":"I","Ð":"D","Ñ":"N","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","×":"x","Ø":"O","Ù":"U","Ú":"U","Û":"U","Ü":"U","Ý":"Y","Þ":"Th","ß":"ss","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","æ":"ae","ç":"c","è":"e","é":"e","ê":"e","ë":"e","ì":"i","í":"i","î":"i","ï":"i","ð":"d","ñ":"n","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","ù":"u","ú":"u","û":"u","ü":"u","ý":"y","þ":"th","ÿ":"y","Ā":"A","ā":"a","Ă":"A","ă":"a","Ą":"A","ą":"a","Ć":"C","ć":"c","Ĉ":"C","ĉ":"c","Ċ":"C","ċ":"c","Č":"C","č":"c","Ď":"D","ď":"d","Đ":"D","đ":"d","Ē":"E","ē":"e","Ĕ":"E","ĕ":"e","Ė":"E","ė":"e","Ę":"E","ę":"e","Ě":"E","ě":"e","Ĝ":"G","ĝ":"g","Ğ":"G","ğ":"g","Ġ":"G","ġ":"g","Ģ":"G","ģ":"g","Ĥ":"H","ĥ":"h","Ħ":"H","ħ":"h","Ĩ":"I","ĩ":"i","Ī":"I","ī":"i","Ĭ":"I","ĭ":"i","Į":"I","į":"i","İ":"I","ı":"i","IJ":"IJ","ij":"ij","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","ĺ":"l","Ļ":"L","ļ":"l","Ľ":"L","ľ":"l","Ŀ":"L","ŀ":"l","Ł":"L","ł":"l","Ń":"N","ń":"n","Ņ":"N","ņ":"n","Ň":"N","ň":"n","ʼn":"'n","Ŋ":"NG","ŋ":"ng","Ō":"O","ō":"o","Ŏ":"O","ŏ":"o","Ő":"O","ő":"o","Œ":"OE","œ":"oe","Ŕ":"R","ŕ":"r","Ŗ":"R","ŗ":"r","Ř":"R","ř":"r","Ś":"S","ś":"s","Ŝ":"S","ŝ":"s","Ş":"S","ş":"s","Š":"S","š":"s","Ţ":"T","ţ":"t","Ť":"T","ť":"t","Ŧ":"T","ŧ":"t","Ũ":"U","ũ":"u","Ū":"U","ū":"u","Ŭ":"U","ŭ":"u","Ů":"U","ů":"u","Ű":"U","ű":"u","Ų":"U","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","ź":"z","Ż":"Z","ż":"z","Ž":"Z","ž":"z"},_={},j=function(){function e(){R(this,e),this.approximations={};for(var r in k)this.approximate(r,k[r])}return U(e,null,[{key:"getInstance",value:function(r){return _[r]=_[r]||new e,_[r]}}]),U(e,[{key:"approximate",value:function(e,r){this.approximations[e]=r}},{key:"transliterate",value:function(e,r){var n=this;return e.replace(/[^\u0000-\u007f]/g,function(e){return n.approximations[e]||r||"?"})}}]),e}();e.pluralize=o,e.singularize=l,e.camelize=p,e.underscore=$,e.humanize=g,e.titleize=f,e.tableize=h,e.classify=v,e.dasherize=y,e.foreignKey=m,e.ordinal=d,e.ordinalize=w,e.transliterate=b,e.parameterize=C,e.capitalize=c,e.inflections=s,e.transliterations=x,e.constantify=z,Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "inflected",
"version": "2.0.2",
"version": "2.0.3",
"description": "A port of ActiveSupport's inflector to Node.js",

@@ -20,2 +20,3 @@ "main": "dist/umd/inflected.js",

"capitalize",
"constantify",
"dasherize",

@@ -22,0 +23,0 @@ "ordinalize",

@@ -334,2 +334,19 @@ # inflected

### Inflector.constantify
```js
string constantify(string words)
```
Converts words (camelCased, under_scored, or dasherized) to CONSTANT_CASE.
```js
Inflector.constantify('bankAccount') // => 'BANK_ACCOUNT'
Inflector.constantify('bank-account') // => 'BANK_ACCOUNT'
Inflector.constantify('bank_account') // => 'BANK_ACCOUNT'
Inflector.constantify('Bank Account') // => 'BANK_ACCOUNT'
```
## Contributing

@@ -336,0 +353,0 @@

@@ -18,1 +18,2 @@ export { default as pluralize } from "./pluralize";

export { default as transliterations } from "./transliterations";
export { default as constantify } from "./constantify";
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc