Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/pujansrt/commons-utils
- Owner: pujansrt
- Created: 2017-01-07T13:57:35.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2024-08-27T20:03:12.000Z (4 months ago)
- Last Synced: 2024-12-16T14:14:51.902Z (7 days ago)
- Topics: javascript, typescript, utility-library
- Language: TypeScript
- Homepage:
- Size: 58.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
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 NAMECommonsUtils.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);
```