Skip to content

Commit

Permalink
Clean up code for null checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
fdb committed Mar 11, 2018
1 parent ed1c037 commit 855bcb2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/libraries/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ g.shuffle = function (l, seed) {
};

g.slice = function (l, start, size, invert) {
if (!l) { return []; }
if (!l) return [];
var firstList, secondList;
if (!invert) {
return l.slice(start, start + size);
Expand All @@ -214,7 +214,7 @@ g.slice = function (l, start, size, invert) {
};

g.sort = function (l, key) {
if (!l) { return []; }
if (!l) return [];
if (key) {
if (typeof key === 'string') {
return l.slice().sort(function (a, b) {
Expand Down Expand Up @@ -242,6 +242,7 @@ g.switch = function (index) {
};

g.takeEvery = function (l, n, offset) {
if (!l) return [];
var i, results = [];
offset = offset || 0;
for (i = 0; i < l.length; i += 1) {
Expand Down

0 comments on commit 855bcb2

Please sign in to comment.