Comparing version 0.0.1 to 0.1.0
@@ -49,2 +49,22 @@ "use strict"; | ||
ObjectWithArrayMethodsOptimized.prototype.keys = function keys(){ | ||
return Object.keys(this._object); | ||
}; | ||
ObjectWithArrayMethodsOptimized.prototype.values = function values(){ | ||
if(typeof Object.values === 'function'){ | ||
return Object.values(arr); | ||
} | ||
var arr = []; | ||
var oThis=this._object; | ||
for(var attr in oThis){ if(oThis.hasOwnProperty(attr)){ | ||
arr.push(oThis[attr]); | ||
}} | ||
return arr; | ||
}; | ||
ObjectWithArrayMethodsOptimized.prototype.join = function join(separator){ | ||
return this.values().join(separator); | ||
}; | ||
function ArrayAndKeys2Object(result, keys){ | ||
@@ -64,4 +84,9 @@ var adapted = {}; | ||
{name:'filter' , resultAdapt: Argument3Adapt, stepAdapt:function(x, v, n, a){ if(x){a[n]=v;} }}, | ||
{name:'join' , useOptimized: true }, | ||
{name:'values' , useOptimized: true }, | ||
{name:'keys' , useOptimized: true }, | ||
].forEach(function(method){ | ||
ObjectWithArrayMethodsNonOptimized.prototype[method.name] = function (f, fThis){ | ||
ObjectWithArrayMethodsNonOptimized.prototype[method.name] = method.useOptimized ? | ||
ObjectWithArrayMethodsOptimized.prototype[method.name] : | ||
function (f, fThis){ | ||
var oThis=this._object; | ||
@@ -72,3 +97,6 @@ var keys=Object.keys(oThis); | ||
var arrayValue=oThis[arrayKey]; | ||
return (method.stepAdapt||id)(f.call(fThis, arrayValue, arrayKey, oThis), arrayValue, arrayKey, acumulator); | ||
return (method.stepAdapt||id)( | ||
typeof f === "function" ? f.call(fThis, arrayValue, arrayKey, oThis) : f, | ||
arrayValue, arrayKey, acumulator | ||
); | ||
}, fThis); | ||
@@ -75,0 +103,0 @@ return (method.resultAdapt||id)(result, keys, acumulator); |
{ | ||
"name": "like-ar", | ||
"description": "Using objects like arrays with map, filter, forEach and others coming soon.", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"author": "Codenautas <codenautas@googlegroups.com>", | ||
@@ -17,5 +17,5 @@ "repository": "codenautas/like-ar", | ||
"istanbul": "~0.4.5", | ||
"mocha": "~3.2.0", | ||
"mocha": "~3.3.0", | ||
"json4all": "~0.3.0" | ||
"json4all": "~0.3.3" | ||
}, | ||
@@ -22,0 +22,0 @@ "engines": { |
@@ -5,3 +5,3 @@ # like-ar | ||
![designing](https://img.shields.io/badge/stability-designing-red.svg) | ||
![extending](https://img.shields.io/badge/stability-extending-orange.svg) | ||
[![npm-version](https://img.shields.io/npm/v/like-ar.svg)](https://npmjs.org/package/like-ar) | ||
@@ -8,0 +8,0 @@ [![downloads](https://img.shields.io/npm/dm/like-ar.svg)](https://npmjs.org/package/like-ar) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8272
114