Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/heimdallrj/js-prototype
Modified prototype methods for JS
https://github.com/heimdallrj/js-prototype
javascript js js-prototype
Last synced: about 24 hours ago
JSON representation
Modified prototype methods for JS
- Host: GitHub
- URL: https://github.com/heimdallrj/js-prototype
- Owner: heimdallrj
- License: mit
- Created: 2018-04-17T06:09:26.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-04-26T17:51:35.000Z (over 6 years ago)
- Last Synced: 2024-08-09T21:13:36.094Z (5 months ago)
- Topics: javascript, js, js-prototype
- Language: JavaScript
- Size: 9.77 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# js-prototype
[![npm](https://img.shields.io/npm/v/js-prototype.svg)](https://www.npmjs.com/package/js-prototype)
[![license](https://img.shields.io/github/license/thinkholic/js-prototype.svg)](https://github.com/thinkholic/js-prototype/blob/master/LICENSE)Modified prototype methods for JS
## Installation
```
npm i -S js-prototype
```## Usage
### String
#### String.allReplace()
```js
require 'js-prototype'; // or require 'js-prototype/string';var str = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.';
var list = {
'ipsum': 'REPLACED-ipsum',
'amet': 'REPLACED-amet'
};
var newStr = str.allReplace(list);
console.log(newStr); // Lorem REPLACED-ipsum dolor sit REPLACED-amet, consectetur adipiscing elit.
```#### String.toTitleCase()
```js
require 'js-prototype'; // or require 'js-prototype/string';var str = 'Lorem ipsum dolor';
var result = str.toTitleCase();
console.log(result); // Lorem Ipsum Dolor```
### Object
#### Object.isEmpty()
```js
require 'js-prototype'; // or require 'js-prototype/object';const a = {};
const b = {a: 1, b:3};
console.log(a.isEmpty()); // true
console.log(b.isEmpty()); // false
```### Array
#### Array.drop()
```js
require 'js-prototype'; // or require 'js-prototype/array';// By Value
const arr = [1, 2, 3, 4, 5, 6];
arr.drop(2);
console.log(arr); // [1, 3, 4, 5, 6]// By Index
arr.drop(null, 0);
console.log(arr); // [3, 4, 5, 6]
```## License
MIT