Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

like-ar

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

like-ar - npm Package Compare versions

Comparing version 0.2.10 to 0.2.11

1

like-ar.d.ts

@@ -6,2 +6,3 @@ declare module "like-ar"{

filter :( callback:(value:T , key:string)=>boolean) => ObjectWithArrayFunctions<T>
build :<U>( callback:(value:T, key:string)=>{[key:string]:U}) => ObjectWithArrayFunctions<U>
keys :() => string[]

@@ -8,0 +9,0 @@ array :() => T[]

@@ -99,2 +99,3 @@ "use strict";

{name:'plain' , useOptimized: true },
{name:'build' , useOptimized: true },
].forEach(function(method){

@@ -131,2 +132,14 @@ ObjectWithArrayMethodsNonOptimized.prototype[method.name] = method.useOptimized ?

ObjectWithArrayMethodsOptimized.prototype.build = function build(f, fThis){
var oThis=this._object;
var acumulator = likeAr();
for(var attr in oThis){ if(oThis.hasOwnProperty(attr)){
var result = f.call(fThis, oThis[attr], attr, oThis);
for(var attrResult in result){
acumulator[attrResult]=result[attrResult];
}
}}
return acumulator;
};
ObjectWithArrayMethodsOptimized.prototype.filter = function filter(f, fThis){

@@ -133,0 +146,0 @@ var oThis=this._object;

2

package.json
{
"name": "like-ar",
"description": "Using objects like arrays with map, filter, forEach and others coming soon.",
"version": "0.2.10",
"version": "0.2.11",
"author": "Codenautas <codenautas@googlegroups.com>",

@@ -6,0 +6,0 @@ "repository": "codenautas/like-ar",

@@ -70,2 +70,21 @@ # like-ar

## likeAr(object).build(cb(value, key))
Builds a new object with new keys.
The callback function must return a `{key: value}` object to compose the final result.
```ts
var pairs=[{field:'lastName', value:'Perez'}, {field:'firstName', value:'Diego'}];
console.log(likeAr(pairs).build(funciton(pair){ return {[pair.field]: pair.value}; ));
// {lastName: "Perez", firstName: "Diego"}
var toJoin=[{lastName:'Perez'}, {firstName:'Diego'}];
console.log(likeAr(toJoin).build(funciton(objectWithOneKey){ return objectWithOneKey; ));
// {lastName: "Perez", firstName: "Diego"}
```
## likeAr.toPlainObject(array [,keyName [,valueName]])

@@ -72,0 +91,0 @@ ## likeAr.toPlainObject(arrayOfKeys, arrayOfValues)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc