Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
Ardalan Amini committed May 29, 2018
2 parents 54fbf5d + 79f6eb0 commit c0c38ef
Show file tree
Hide file tree
Showing 25 changed files with 518 additions and 190 deletions.
91 changes: 91 additions & 0 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
* [.deepFlatten()](#Array+deepFlatten)[<code>Array</code>](#Array)
* [.diff(array, [comp])](#Array+diff)[<code>Array</code>](#Array)
* [.distinct()](#Array+distinct)[<code>Array</code>](#Array)
* [.empty()](#Array+empty) ⇒ <code>boolean</code>
* [.everyNth()](#Array+everyNth)[<code>Array</code>](#Array)
* [.first()](#Array+first) ⇒ <code>\*</code>
* [.flatten([depth])](#Array+flatten)[<code>Array</code>](#Array)
Expand Down Expand Up @@ -334,6 +335,17 @@ Returns all the distinct values of an array
```javascript
[1, 2, 2, 3, 4, 4, 5].distinct(); // [1,2,3,4,5]
```
<a name="Array+empty"></a>

### array.empty() ⇒ <code>boolean</code>
Checks if the array is empty

**Kind**: instance method of [<code>Array</code>](#Array)
**Example**
```javascript
[1,2].empty(); // false
[].empty(); // true
```
<a name="Array+everyNth"></a>

### array.everyNth() ⇒ [<code>Array</code>](#Array)
Expand Down Expand Up @@ -1235,6 +1247,26 @@ Math.lcm(...[1, 3, 4, 5]); // 60

## Number : <code>object</code>
**Kind**: global namespace

* [Number](#Number) : <code>object</code>
* [.digitize](#Number.digitize) ⇒ <code>Array.&lt;number&gt;</code>
* [.isInstance](#Number.isInstance) ⇒ <code>boolean</code>

<a name="Number.digitize"></a>

### Number.digitize ⇒ <code>Array.&lt;number&gt;</code>
Converts the number to an array of digits

**Kind**: static property of [<code>Number</code>](#Number)

| Param | Type |
| --- | --- |
| num | <code>number</code> |

**Example**
```javascript
Number.digitize(123); // [1, 2, 3]
```
<a name="Number.isInstance"></a>

### Number.isInstance ⇒ <code>boolean</code>
Expand All @@ -1260,6 +1292,7 @@ Number.isInstance(2); // true
* _instance_
* [.$camelCaseKeys()](#Object+$camelCaseKeys)[<code>Object</code>](#Object)
* [.$clone(deep)](#Object+$clone)[<code>Object</code>](#Object)
* [.$empty()](#Object+$empty) ⇒ <code>boolean</code>
* [.$equals(obj)](#Object+$equals) ⇒ <code>boolean</code>
* [.$get(key)](#Object+$get) ⇒ <code>\*</code>
* [.$invert()](#Object+$invert)[<code>Object</code>](#Object)
Expand Down Expand Up @@ -1301,6 +1334,17 @@ Creates a (deep) clone of the object
const a = { foo: 'bar', obj: { a: 1, b: 2 } };
const b = a.$clone(true); // a !== b, a.obj !== b.obj
```
<a name="Object+$empty"></a>

### object.$empty() ⇒ <code>boolean</code>
Checks if the object is empty

**Kind**: instance method of [<code>Object</code>](#Object)
**Example**
```javascript
{ a: 1 }.$empty(); // false
{}.$empty(); // true
```
<a name="Object+$equals"></a>

### object.$equals(obj) ⇒ <code>boolean</code>
Expand Down Expand Up @@ -1492,11 +1536,13 @@ Object.isInstance({foo: 'bar'}); // true
* [.chars()](#String+chars) ⇒ <code>Array.&lt;string&gt;</code>
* [.contains(pattern)](#String+contains) ⇒ <code>Array.&lt;string&gt;</code>
* [.decapitalize([allWords])](#String+decapitalize) ⇒ <code>string</code>
* [.empty()](#String+empty) ⇒ <code>boolean</code>
* [.humanize()](#String+humanize) ⇒ <code>string</code>
* [.kebabCase()](#String+kebabCase) ⇒ <code>string</code>
* [.lines()](#String+lines) ⇒ <code>Array.&lt;string&gt;</code>
* [.map(fn)](#String+map) ⇒ <code>Array.&lt;string&gt;</code>
* [.mask([num], [mask])](#String+mask) ⇒ <code>string</code>
* [.pad(size, [value])](#String+pad)[<code>String</code>](#String)
* [.pluralize([value])](#String+pluralize) ⇒ <code>string</code>
* [.reverse()](#String+reverse) ⇒ <code>string</code>
* [.singularize()](#String+singularize) ⇒ <code>string</code>
Expand All @@ -1506,6 +1552,7 @@ Object.isInstance({foo: 'bar'}); // true
* [.words(pattern)](#String+words) ⇒ <code>Array.&lt;string&gt;</code>
* _static_
* [.isInstance](#String.isInstance) ⇒ <code>boolean</code>
* [.repeat](#String.repeat)[<code>String</code>](#String)

<a name="String+base64"></a>

Expand Down Expand Up @@ -1599,6 +1646,17 @@ Returns the decapitalized string
'Foo Bar'.decapitalize(); // 'foo Bar'
'Hello World'.decapitalize(true); // 'hello world'
```
<a name="String+empty"></a>

### string.empty() ⇒ <code>boolean</code>
Checks if the string is empty

**Kind**: instance method of [<code>String</code>](#String)
**Example**
```javascript
"123".empty(); // false
"".empty(); // true
```
<a name="String+humanize"></a>

### string.humanize() ⇒ <code>string</code>
Expand Down Expand Up @@ -1669,6 +1727,23 @@ Replaces all but the last num of characters with the specified mask character
'1234567890'.mask(3); // '*******890'
'1234567890'.mask(-4, '$'); // '$$$$567890'
```
<a name="String+pad"></a>

### string.pad(size, [value]) ⇒ [<code>String</code>](#String)
FillS the string with the given value until the string reaches the specified size

**Kind**: instance method of [<code>String</code>](#String)

| Param | Type | Default |
| --- | --- | --- |
| size | <code>number</code> | |
| [value] | [<code>String</code>](#String) | <code>&quot; &quot;</code> |

**Example**
```javascript
"123".pad(5, 0); // "12300"
"123".pad(-5, 0); // "00123"
```
<a name="String+pluralize"></a>

### string.pluralize([value]) ⇒ <code>string</code>
Expand Down Expand Up @@ -1787,3 +1862,19 @@ Returns true if the given argument is an string
String.isInstance(2); // false
String.isInstance("foo bar"); // true
```
<a name="String.repeat"></a>

### String.repeat ⇒ [<code>String</code>](#String)
Initializes and fills an string with the specified value

**Kind**: static property of [<code>String</code>](#String)

| Param | Type | Default |
| --- | --- | --- |
| n | <code>number</code> | |
| [value] | <code>string</code> | <code>&quot;\&quot; \&quot;&quot;</code> |

**Example**
```javascript
String.repeat(5, "2"); // "22222"
```
26 changes: 17 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
# Changelog


## [next](https://github.com/ardalanamini/prototyped.js/releases/tag/next) *(2018-__-__)*
## [v0.9.0](https://github.com/ardalanamini/prototyped.js/releases/tag/v0.9.0) *(2018-05-29)*
**Implemented enhancements:**
- `Array.prototype`
- function `empty` added
- `Number`
- function `digitize` added
- `Object.prototype`
- function `$empty` added
- `String.prototype`
- function `empty` added
- function `pad` added
- function `repeat` added


## [v0.8.0](https://github.com/ardalanamini/prototyped.js/releases/tag/v0.8.0) *(2018-05-25)*
**Implemented enhancements:**
- `Array.prototype`
- function `nest` added
- `Object.prototype`
- function `merge` improved
- function `clone` added
- function `equals` added
- function `get` added
- function `omit` added
- function `$merge` improved
- function `$clone` added
- function `$equals` added
- function `$get` added
- function `$omit` added


## [v0.7.0](https://github.com/ardalanamini/prototyped.js/releases/tag/v0.7.0) *(2018-05-20)*
**Implemented enhancements:**
- `Object.prototype`
- function `camelCaseKeys` added
- function `kebabCaseKeys` added
- function `snakeCaseKeys` added
- function `$camelCaseKeys` added
- function `$kebabCaseKeys` added
- function `$snakeCaseKeys` added


## [v0.6.0](https://github.com/ardalanamini/prototyped.js/releases/tag/v0.6.0) *(2018-05-11)*
Expand Down
19 changes: 19 additions & 0 deletions lib/array/empty/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as method from "./method";

declare global {
interface Array<T> {
empty(): boolean;
}
}

/**
* Checks if the array is empty
* @memberof Array
* @returns {boolean}
* @example
* [1,2].empty(); // false
* [].empty(); // true
*/
Array.prototype.empty = function() {
return method(this);
};
3 changes: 3 additions & 0 deletions lib/array/empty/method.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const method = (arr: any[]) => arr.length === 0;

export = method;
11 changes: 11 additions & 0 deletions lib/array/empty/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import "./index";

describe("Array.prototype.empty", () => {
test("[1,2].empty() returns false", () => {
expect([1, 2].empty()).toEqual(false);
});

test("[].empty() returns true", () => {
expect([].empty()).toBe(true);
});
});
1 change: 1 addition & 0 deletions lib/array/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import "./crossJoin";
import "./deepFlatten";
import "./diff";
import "./distinct";
import "./empty";
import "./everyNth";
import "./first";
import "./flatten";
Expand Down
2 changes: 2 additions & 0 deletions lib/array/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import * as crossJoin from "./crossJoin/method";
import * as deepFlatten from "./deepFlatten/method";
import * as diff from "./diff/method";
import * as distinct from "./distinct/method";
import * as empty from "./empty/method";
import * as everyNth from "./everyNth/method";
import * as first from "./first/method";
import * as flatten from "./flatten/method";
Expand Down Expand Up @@ -69,6 +70,7 @@ export {
deepFlatten,
diff,
distinct,
empty,
everyNth,
first,
flatten,
Expand Down
22 changes: 22 additions & 0 deletions lib/object/empty/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as method from "./method";
import { addPrototype } from "../utils";

declare global {
interface Object {
$empty(): boolean;
}
}

/**
* Checks if the object is empty
* @memberof Object.prototype
* @returns {boolean}
* @example
* { a: 1 }.$empty(); // false
* {}.$empty(); // true
*/
function $empty(this: object): boolean {
return method(this);
}

addPrototype("$empty", $empty);
5 changes: 5 additions & 0 deletions lib/object/empty/method.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as size from "../size/method";

const method = (obj: object) => size(obj) === 0;

export = method;
11 changes: 11 additions & 0 deletions lib/object/empty/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import "./index";

describe("Object.prototype.$empty", () => {
test("{ a: 1 }.$empty() returns false", () => {
expect({ a: 1 }.$empty()).toEqual(false);
});

test("{}.$empty() returns true", () => {
expect({}.$empty()).toBe(true);
});
});
1 change: 1 addition & 0 deletions lib/object/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import "./camelCaseKeys";
import "./clone";
import "./empty";
import "./equals";
import "./get";
import "./invert";
Expand Down
2 changes: 2 additions & 0 deletions lib/object/methods.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as camelCaseKeys from "./camelCaseKeys/method";
import * as clone from "./clone/method";
import * as empty from "./empty/method";
import * as equals from "./equals/method";
import * as get from "./get/method";
import * as invert from "./invert/method";
Expand All @@ -16,6 +17,7 @@ import * as snakeCaseKeys from "./snakeCaseKeys/method";
export {
camelCaseKeys,
clone,
empty,
equals,
get,
invert,
Expand Down
19 changes: 19 additions & 0 deletions lib/string/empty/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as method from "./method";

declare global {
interface String {
empty(): boolean;
}
}

/**
* Checks if the string is empty
* @memberof String
* @returns {boolean}
* @example
* "123".empty(); // false
* "".empty(); // true
*/
String.prototype.empty = function() {
return method(this as string);
};
3 changes: 3 additions & 0 deletions lib/string/empty/method.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const method = (str: string) => str.length === 0;

export = method;
11 changes: 11 additions & 0 deletions lib/string/empty/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import "./index";

describe("String.prototype.empty", () => {
test("\"123\".empty() returns false", () => {
expect("123".empty()).toEqual(false);
});

test("\"\".empty() returns true", () => {
expect("".empty()).toBe(true);
});
});
3 changes: 3 additions & 0 deletions lib/string/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ import "./capitalize";
import "./chars";
import "./contains";
import "./decapitalize";
import "./empty";
import "./humanize";
import "./isInstance";
import "./kebabCase";
import "./lines";
import "./map";
import "./mask";
import "./pad";
import "./pluralize";
import "./repeat";
import "./reverse";
import "./singularize";
import "./snakeCase";
Expand Down
Loading

0 comments on commit c0c38ef

Please sign in to comment.