commons-utils

2.2.0 • Public • Published

Commons Utilities

Common Available Methods

clone;
remove;
shuffle;
sample;
uniq;
compact;
reverse;
union;
intersection;
diff;
flatten;
last;
findIndices;

camelCase;
pascalCase;
titleCase;
toggleCase;
swapCase;
dotCase;
random;
guid;
formatCurrency;
isEmpty;
isInteger;
isNumber;
isJsonString;
isString;
removeHtmlTags;
extractURLs;
extractPhones;
extractEmails;
extractPercent;
extractNumbers;
extractUSCurrencyAndNumbers;
extractHyphenated;
extractTime;
extractDotted;
extractQuoted;
replaceAt;
removeAt;
size;

removeObject;
safeparse;

isValidEmail;
isValidUrl;
isValidImage;
isValidUSA_SSN;
isValidDate;
isValidCreditCard;
isValidCitizenId;

Countries that are supported

Brazil i.e. "BR"
Croatia "HR"
Ireland i.e. "IE"
San Marino ie "SM"
Thailand i.e. "TH"
Turkey i.e. "TR":

How to use it

Install

npm install -S commons-utils

Code Sample

const CommonsUtils = require('commons-utils');

CommonsUtils.dotCase('userName'); //user.name
CommonsUtils.dotCase("user   Name"); // user.name
CommonsUtils.pascalCase("user name"); // userName
CommonsUtils.camelCase("user name"); // userName
CommonsUtils.titleCase("user name"); // User Name
CommonsUtils.toggleCase("user name"); // USER NAME

CommonsUtils.random.alphabetical(5); // qemhI
CommonsUtils.random.alphanumeric(5); // 8Czd5
CommonsUtils.random.numerical(5); // 91125
CommonsUtils.random.default(10,100); // 62
CommonsUtils.random.color("Pujan"); // hsl(210,60%, 70%)
CommonsUtils.random.color(); // #1a157b

Queue Implementations

const q = new Queue();
q.add(1);
q.add(2);
q.add(3);
      

const q = new LimitedQueue(5);

const lruCache = new lruCache(5);

Package Sidebar

Install

npm i commons-utils

Weekly Downloads

0

Version

2.2.0

License

MIT

Unpacked Size

36.4 kB

Total Files

3

Last publish

Collaborators

  • pujansrt