Skip to content

Instantly share code, notes, and snippets.

@crossRT
crossRT / chunk.js
Created December 26, 2017 02:37
Plain JavaScript chunk
function chunk(array, size) {
return array.reduce(function (res, item, index) {
if (index % size === 0) {
res.push([]);
}
res[res.length - 1].push(item);
return res;
}, []);
}
@crossRT
crossRT / HasEnums.php
Created April 29, 2016 01:28 — forked from themsaid/HasEnums.php
PHP Enumerated Type
trait HasEnums
{
/**
* The array of enumerators of a given group.
*
* @param null|string $group
* @return array
*/
static function enums($group = null)
{