@mongez/reinforcements 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ const users = collection.where('age', '>', 25);
|
|
|
43
43
|
const users = collection.where('age', '>', 25).where('age', '<', 30);
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
You can see the entire documentation in [Collection](./docs/
|
|
46
|
+
You can see the entire documentation in [Collection](./docs/collection.md) Page.
|
|
47
47
|
|
|
48
48
|
## Working with objects
|
|
49
49
|
|
|
@@ -87,6 +87,10 @@ export default class ImmutableCollection {
|
|
|
87
87
|
*/
|
|
88
88
|
multiply(amount: number): any;
|
|
89
89
|
multiply(key: string, amount: number): any;
|
|
90
|
+
/**
|
|
91
|
+
* Double the given key in each element or the element by 2
|
|
92
|
+
*/
|
|
93
|
+
double(key?: string): any;
|
|
90
94
|
/**
|
|
91
95
|
* Divide the given amount to each element or given key in each element
|
|
92
96
|
*/
|
|
@@ -236,6 +236,12 @@ var ImmutableCollection = /** @class */ (function () {
|
|
|
236
236
|
return item * amount;
|
|
237
237
|
});
|
|
238
238
|
};
|
|
239
|
+
/**
|
|
240
|
+
* Double the given key in each element or the element by 2
|
|
241
|
+
*/
|
|
242
|
+
ImmutableCollection.prototype.double = function (key) {
|
|
243
|
+
return key ? this.multiply(key, 2) : this.multiply(2);
|
|
244
|
+
};
|
|
239
245
|
ImmutableCollection.prototype.divide = function () {
|
|
240
246
|
var args = [];
|
|
241
247
|
for (var _i = 0; _i < arguments.length; _i++) {
|
package/docs/collection.md
CHANGED
|
@@ -1750,6 +1750,26 @@ const users = collect([
|
|
|
1750
1750
|
users.multiply('age', 2); // [{ name: 'John', age: 40 }, { name: 'Jane', age: 50 }, { name: 'Jack', age: 60 }]
|
|
1751
1751
|
```
|
|
1752
1752
|
|
|
1753
|
+
You can also double numbers directly by using `double` method.
|
|
1754
|
+
|
|
1755
|
+
```ts
|
|
1756
|
+
const numbers = collect([1, 2, 3, 4, 5]);
|
|
1757
|
+
|
|
1758
|
+
numbers.double(); // [2, 4, 6, 8, 10]
|
|
1759
|
+
```
|
|
1760
|
+
|
|
1761
|
+
Double key values
|
|
1762
|
+
|
|
1763
|
+
```ts
|
|
1764
|
+
const users = collect([
|
|
1765
|
+
{ name: 'John', age: 20 },
|
|
1766
|
+
{ name: 'Jane', age: 25 },
|
|
1767
|
+
{ name: 'Jack', age: 30 },
|
|
1768
|
+
]);
|
|
1769
|
+
|
|
1770
|
+
users.double('age'); // [{ name: 'John', age: 40 }, { name: 'Jane', age: 50 }, { name: 'Jack', age: 60 }]
|
|
1771
|
+
```
|
|
1772
|
+
|
|
1753
1773
|
## Divide
|
|
1754
1774
|
|
|
1755
1775
|
The `divide` method divide the given value to each element of the array.
|
|
@@ -87,6 +87,10 @@ export default class ImmutableCollection {
|
|
|
87
87
|
*/
|
|
88
88
|
multiply(amount: number): any;
|
|
89
89
|
multiply(key: string, amount: number): any;
|
|
90
|
+
/**
|
|
91
|
+
* Double the given key in each element or the element by 2
|
|
92
|
+
*/
|
|
93
|
+
double(key?: string): any;
|
|
90
94
|
/**
|
|
91
95
|
* Divide the given amount to each element or given key in each element
|
|
92
96
|
*/
|
|
@@ -224,6 +224,12 @@ var ImmutableCollection = /** @class */ (function () {
|
|
|
224
224
|
return item * amount;
|
|
225
225
|
});
|
|
226
226
|
};
|
|
227
|
+
/**
|
|
228
|
+
* Double the given key in each element or the element by 2
|
|
229
|
+
*/
|
|
230
|
+
ImmutableCollection.prototype.double = function (key) {
|
|
231
|
+
return key ? this.multiply(key, 2) : this.multiply(2);
|
|
232
|
+
};
|
|
227
233
|
ImmutableCollection.prototype.divide = function () {
|
|
228
234
|
var args = [];
|
|
229
235
|
for (var _i = 0; _i < arguments.length; _i++) {
|
package/package.json
CHANGED