-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(globals): add couple of globals
- Loading branch information
1 parent
b966077
commit f1bf6e0
Showing
3 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
'use strict' | ||
|
||
/* | ||
* edge | ||
* | ||
* (c) Harminder Virk <virk@adonisjs.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
const _ = require('lodash') | ||
|
||
const range = function (start, end) { | ||
return _.range(start, end) | ||
} | ||
|
||
const batch = function (input, size) { | ||
return _.chunk(input, size) | ||
} | ||
|
||
const toJSON = function (input, indent = 2) { | ||
return JSON.stringify(input, null, indent) | ||
} | ||
|
||
const first = function (collection) { | ||
return _.first(collection) | ||
} | ||
|
||
const last = function (collection) { | ||
return _.last(collection) | ||
} | ||
|
||
const groupBy = function (collection, field) { | ||
return _.groupBy(collection, field) | ||
} | ||
|
||
const size = function (input) { | ||
return _.size(input) | ||
} | ||
|
||
module.exports = { | ||
range, | ||
batch, | ||
toJSON, | ||
first, | ||
last, | ||
groupBy, | ||
size | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters