Skip to content

Commit

Permalink
1.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fishcharlie committed Apr 1, 2018
1 parent 0257903 commit 2463b08
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dist/browser/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 56 additions & 1 deletion dist/node/array/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use strict";
'use strict';

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }

Expand Down Expand Up @@ -76,4 +76,59 @@ Array.prototype.first = function () {

Array.prototype.last = function () {
return this[this.length - 1];
};

/* istanbul ignore if */
if (!Array.prototype.fill) {
Object.defineProperty(Array.prototype, 'fill', {
value: function value(_value) {

// Steps 1-2.
if (this == null) {
throw new TypeError('this is null or not defined');
}

var O = Object(this);

// Steps 3-5.
var len = O.length >>> 0;

// Steps 6-7.
var start = arguments[1];
var relativeStart = start >> 0;

// Step 8.
var k = relativeStart < 0 ? Math.max(len + relativeStart, 0) : Math.min(relativeStart, len);

// Steps 9-10.
var end = arguments[2];
var relativeEnd = end === undefined ? len : end >> 0;

// Step 11.
var final = relativeEnd < 0 ? Math.max(len + relativeEnd, 0) : Math.min(relativeEnd, len);

// Step 12.
while (k < final) {
O[k] = _value;
k++;
}

// Step 13.
return O;
}
});
}

Array.prototype.frontPad = function (item, length) {
if (isNaN(length)) {
return this;
}
return [].concat(_toConsumableArray(Array(length - this.length > this.length ? length - this.length : 0).fill(item)), _toConsumableArray(this));
};

Array.prototype.backPad = function (item, length) {
if (isNaN(length)) {
return this;
}
return [].concat(_toConsumableArray(this), _toConsumableArray(Array(length - this.length > this.length ? length - this.length : 0).fill(item)));
};
3 changes: 2 additions & 1 deletion dist/node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ require('./string/index.js');
require('./promise/index.js');

var otherNumber = require('./other/number.js');
var timeout = require('./other/timeout.js');
var hash = require('./hash/index.js');
module.exports = _extends({}, otherNumber, hash);
module.exports = _extends({}, otherNumber, hash, timeout);
13 changes: 13 additions & 0 deletions dist/node/other/timeout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"use strict";

module.exports.timeout = function (ms) {
ms = parseInt(ms);
return new Promise(function (resolve, reject) {
if (isNaN(ms)) {
reject("Invalid miliseconds passed in: " + ms);
}
setTimeout(function () {
return resolve();
}, ms);
});
};
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scriptutils",
"version": "1.5.0",
"version": "1.6.0",
"description": "Utilities to make Javascript Easy",
"main": "dist/node/index.js",
"scripts": {
Expand Down Expand Up @@ -66,4 +66,4 @@
"engines": {
"node": ">=4.0"
}
}
}

0 comments on commit 2463b08

Please sign in to comment.