@youngbeen/es-halfmoon
Advanced tools
+5
| { | ||
| "presets": [ | ||
| "@babel/preset-env" | ||
| ] | ||
| } |
+16
-6
@@ -0,3 +1,11 @@ | ||
| "use strict"; | ||
| var isString = function isString(val) { | ||
| return typeof val === 'string'; | ||
| }; | ||
| if (!Array.prototype.get) { | ||
| Array.prototype.get = function (property, keyName = '') { | ||
| Array.prototype.get = function (property) { | ||
| var keyName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; | ||
| // console.log(property, keyName) | ||
@@ -9,7 +17,7 @@ if (property && isString(property)) { | ||
| const sampleItem = this[0]; | ||
| var sampleItem = this[0]; | ||
| if (isObject(sampleItem)) { | ||
| // object item | ||
| const keys = Object.keys(sampleItem); | ||
| var keys = Object.keys(sampleItem); | ||
@@ -32,3 +40,5 @@ if (!keyName) { | ||
| return this.find(item => item[keyName] === property); | ||
| return this.find(function (item) { | ||
| return item[keyName] === property; | ||
| }); | ||
| } else { | ||
@@ -54,4 +64,4 @@ // value item | ||
| for (let index = this.length - 1; index >= 0; index--) { | ||
| const element = this[index]; | ||
| for (var index = this.length - 1; index >= 0; index--) { | ||
| var element = this[index]; | ||
| callbackfn(element, index); | ||
@@ -58,0 +68,0 @@ } |
+1
-1
| { | ||
| "name": "@youngbeen/es-halfmoon", | ||
| "version": "0.1.0", | ||
| "version": "0.1.1", | ||
| "description": "`ES-halfmoon` is about to provide some prototype methods for ES not covered yet", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
+4
-0
| const isString = (val) => { | ||
| return typeof (val) === 'string' | ||
| } | ||
| if (!Array.prototype.get) { | ||
@@ -3,0 +7,0 @@ Array.prototype.get = function (property, keyName = '') { |
5391
6.18%5
25%106
10.42%