Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/pujansrt/commons-utils

Common Utilities Package for JavaScript. Most of implementation are written in ES6. Common Utils are Arrays: Shuffling, diff, flatten. String: isObject, ObjectType, isXXX type, Case: CamelCase, pascalCase, titlecase, toggleCase, swapCase, dotCase, kebabCase, snakeCase and random utilities
https://github.com/pujansrt/commons-utils

javascript typescript utility-library

Last synced: 3 days ago
JSON representation

Common Utilities Package for JavaScript. Most of implementation are written in ES6. Common Utils are Arrays: Shuffling, diff, flatten. String: isObject, ObjectType, isXXX type, Case: CamelCase, pascalCase, titlecase, toggleCase, swapCase, dotCase, kebabCase, snakeCase and random utilities

Awesome Lists containing this project

README

        



# 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

```py
npm install -S commons-utils
```

### Code Sample

```js
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

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

const q = new LimitedQueue(5);

const lruCache = new lruCache(5);
```