A fast deep clone seems like it would be useful. Even better would be if 
> deep equal came with it. (There's a deep equal buried in assert, but not 
> exposed other than as an assertion.)
>

I've done it in js for now. Almost like it's in the lodash.clone.
Unfortunately it's not that fast as expected:

// small object
deep1 lodash _.clone           x  96,368 ops/sec ±0.74% (93 runs sampled)deep1 
node-v8-clone js cloner  x 223,143 ops/sec ±1.34% (85 runs sampled)

// large objectdeep3 lodash _.clone           x       3.87 ops/sec ±0.39% (14 
runs sampled)deep3 node-v8-clone js cloner  x      14.18 ops/sec ±0.33% (39 
runs sampled)

// small arraydeeparr1 lodash _.clone           x 286,019 ops/sec ±1.37% (85 
runs sampled)deeparr1 node-v8-clone js cloner  x 566,595 ops/sec ±1.38% (87 
runs sampled)

// large arraydeeparr2 lodash _.clone           x       2.94 ops/sec ±0.16% (12 
runs sampled)deeparr2 node-v8-clone js cloner  x      16.15 ops/sec ±0.35% (44 
runs sampled)

 

> Note that the original frameworks you mentioned run in the browser as well 
> as in Node, so people writing code to run in both environments would still 
> use those, even if Node has a fast clone built in.
>
> --
> Martin Cooper
>  
>
> четверг, 22 ноября 2012 г., 18:05:18 UTC+7 пользователь Alexey Kupershtokh 
>> написал:
>>
>>> I see that almost every framework (underscore, lodash, moo, etc) creates 
>>> its own clone function.
>>> But v8 engine already has it.
>>> So I've created a module that exposes v8's clone function. Just as a 
>>> proof of concept. It needs assertions and currently fails with a 
>>> segmentation fault on inputs like null values.
>>>
>>> https://github.com/**AlexeyKupershtokh/node-v8-**clone<https://github.com/AlexeyKupershtokh/node-v8-clone>
>>>
>>> According to the benchmarks it's:
>>> 8x faster (50x on 1000-key obj) than this approach:
>>> var result = {}; for (i in obj) result[i] = obj[i];
>>> 12x faster (450x on 1000-key object) than this approach:
>>> var result = {}; for (i in obj) if (obj.hasOwnProperty(i)) result[i] = 
>>> obj[i];
>>>
>>> So I wonder if the community needs this module.
>>> Also node's core developers are welcome to criticize. Is it ok to expose 
>>> this function? What are possible drawbacks? Or maybe it's worth to include 
>>> this into the node.js core?
>>>
>>  -- 
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines: 
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> You received this message because you are subscribed to the Google
>> Groups "nodejs" group.
>> To post to this group, send email to [email protected]<javascript:>
>> To unsubscribe from this group, send email to
>> [email protected] <javascript:>
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>
>
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to