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

@emberx/string

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@emberx/string - npm Package Compare versions

Comparing version 0.0.1 to 0.0.5

dist/cache.js

63

dist/index.js

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

var e={d:(t,s)=>{for(var r in s)e.o(s,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:s[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{et:()=>i,Xn:()=>r,_A:()=>$,kC:()=>v,xk:()=>j,H0:()=>U,Y8:()=>A,It:()=>k});let s={};function r(e){s=e}function i(){return s}function n(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}class a{constructor(e,t,s){n(this,"size",0),n(this,"misses",0),n(this,"hits",0),this.limit=e,this.func=t,this.store=s,this.store=s||new Map}get(e){return this.store.has(e)?(this.hits+=1,this.store.get(e)):(this.misses+=1,this.set(e,this.func(e)))}set(e,t){return this.limit>this.size&&(this.size+=1,this.store.set(e,t)),t}purge(){this.store.clear(),this.size=0,this.hits=0,this.misses=0}}const o=/[ _]/g,c=new a(1e3,(e=>A(e).replace(o,"-"))),u=/(-|_|\.|\s)+(.)?/g,p=/(^|\/)([A-Z])/g,l=new a(1e3,(e=>e.replace(u,((e,t,s)=>s?s.toUpperCase():"")).replace(p,(e=>e.toLowerCase())))),h=/^(-|_)+(.)?/,g=/(.)(-|_|\.|\s)+(.)?/g,f=/(^|\/|\.)([a-z])/g,w=new a(1e3,(e=>{const t=(e,t,s)=>s?`_${s.toUpperCase()}`:"",s=(e,t,s,r)=>t+(r?r.toUpperCase():""),r=e.split("/");for(let e=0;e<r.length;e++)r[e]=r[e].replace(h,t).replace(g,s);return r.join("/").replace(f,(e=>e.toUpperCase()))})),z=/([a-z\d])([A-Z]+)/g,_=/-|\s+/g,C=new a(1e3,(e=>e.replace(z,"$1_$2").replace(_,"_").toLowerCase())),d=/(^|\/)([a-z\u00C0-\u024F])/g,m=new a(1e3,(e=>e.replace(d,(e=>e.toUpperCase())))),b=/([a-z\d])([A-Z])/g,y=new a(1e3,(e=>e.replace(b,"$1_$2").toLowerCase()));function A(e){return y.get(e)}function U(e){return c.get(e)}function $(e){return l.get(e)}function j(e){return w.get(e)}function k(e){return C.get(e)}function v(e){return m.get(e)}var O=t.et,x=t.Xn,L=t._A,P=t.kC,Z=t.xk,H=t.H0,I=t.Y8,S=t.It;export{O as _getStrings,x as _setStrings,L as camelize,P as capitalize,Z as classify,H as dasherize,I as decamelize,S as underscore};
import { getStrings, setStrings } from "./string-registry";
import Cache from "./cache";
const STRING_DASHERIZE_REGEXP = /[ _]/g;
const STRING_DASHERIZE_CACHE = new Cache(1e3, (key) => decamelize(key).replace(STRING_DASHERIZE_REGEXP, "-"));
const STRING_CAMELIZE_REGEXP_1 = /(-|_|\.|\s)+(.)?/g;
const STRING_CAMELIZE_REGEXP_2 = /(^|\/)([A-Z])/g;
const CAMELIZE_CACHE = new Cache(1e3, (key) => key.replace(STRING_CAMELIZE_REGEXP_1, (_match, _separator, chr) => chr ? chr.toUpperCase() : "").replace(STRING_CAMELIZE_REGEXP_2, (match) => match.toLowerCase()));
const STRING_CLASSIFY_REGEXP_1 = /^(-|_)+(.)?/;
const STRING_CLASSIFY_REGEXP_2 = /(.)(-|_|\.|\s)+(.)?/g;
const STRING_CLASSIFY_REGEXP_3 = /(^|\/|\.)([a-z])/g;
const CLASSIFY_CACHE = new Cache(1e3, (str) => {
const replace1 = (_match, _separator, chr) => chr ? `_${chr.toUpperCase()}` : "";
const replace2 = (_match, initialChar, _separator, chr) => initialChar + (chr ? chr.toUpperCase() : "");
const parts = str.split("/");
for (let i = 0; i < parts.length; i++) {
parts[i] = parts[i].replace(STRING_CLASSIFY_REGEXP_1, replace1).replace(STRING_CLASSIFY_REGEXP_2, replace2);
}
return parts.join("/").replace(STRING_CLASSIFY_REGEXP_3, (match) => match.toUpperCase());
});
const STRING_UNDERSCORE_REGEXP_1 = /([a-z\d])([A-Z]+)/g;
const STRING_UNDERSCORE_REGEXP_2 = /-|\s+/g;
const UNDERSCORE_CACHE = new Cache(1e3, (str) => str.replace(STRING_UNDERSCORE_REGEXP_1, "$1_$2").replace(STRING_UNDERSCORE_REGEXP_2, "_").toLowerCase());
const STRING_CAPITALIZE_REGEXP = /(^|\/)([a-z\u00C0-\u024F])/g;
const CAPITALIZE_CACHE = new Cache(1e3, (str) => str.replace(STRING_CAPITALIZE_REGEXP, (match) => match.toUpperCase()));
const STRING_DECAMELIZE_REGEXP = /([a-z\d])([A-Z])/g;
const DECAMELIZE_CACHE = new Cache(1e3, (str) => str.replace(STRING_DECAMELIZE_REGEXP, "$1_$2").toLowerCase());
function _fmt(str, formats) {
let idx = 0;
return str.replace(/%@([0-9]+)?/g, (_s, argIndex) => {
const i = argIndex ? parseInt(argIndex, 10) - 1 : idx++;
const r = i < formats.length ? formats[i] : void 0;
return typeof r === "string" ? r : r === null ? "(null)" : r === void 0 ? "" : String(r);
});
}
function decamelize(str) {
return DECAMELIZE_CACHE.get(str);
}
function dasherize(str) {
return STRING_DASHERIZE_CACHE.get(str);
}
function camelize(str) {
return CAMELIZE_CACHE.get(str);
}
function classify(str) {
return CLASSIFY_CACHE.get(str);
}
function underscore(str) {
return UNDERSCORE_CACHE.get(str);
}
function capitalize(str) {
return CAPITALIZE_CACHE.get(str);
}
export {
getStrings as _getStrings,
setStrings as _setStrings,
camelize,
capitalize,
classify,
dasherize,
decamelize,
underscore
};

7

package.json
{
"name": "@emberx/string",
"type": "module",
"version": "0.0.1",
"version": "0.0.5",
"author": "Izel Nakri",

@@ -14,3 +14,4 @@ "description": "",

},
"license": "ISC"
}
"license": "ISC",
"dependencies": []
}
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