Skip to content

Commit

Permalink
feat: array.isEmpty method
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Aug 18, 2017
1 parent 595c341 commit b0cfbdd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions array/#/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module.exports = {
"indexesOf": require("./indexes-of"),
"intersection": require("./intersection"),
"isCopy": require("./is-copy"),
"isEmpty": require("./is-empty"),
"isUniq": require("./is-uniq"),
"last": require("./last"),
"lastIndex": require("./last-index"),
Expand Down
8 changes: 8 additions & 0 deletions array/#/is-empty.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"use strict";

var ensureArray = require("../../object/ensure-array")
, firstIndex = require("./first-index");

module.exports = function () {
return firstIndex.call(ensureArray(this)) === null;
};
8 changes: 8 additions & 0 deletions test/array/#/is-empty.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"use strict";

module.exports = function (t, a) {
var x = {};
a(t.call([]), true, "Empty");
a(t.call({ length: 0 }), true, "Empty lists");
a(t.call([1, x, "raz"]), false, "Non empty");
};

0 comments on commit b0cfbdd

Please sign in to comment.