kessler / node-regedit

Read, Write, List and do all sorts of funky stuff to the windows registry using node.js and windows script host
MIT License
277 stars 45 forks source link

array of keys empty after calling createKey #10

Closed BilalBoulifa closed 9 years ago

BilalBoulifa commented 9 years ago

after calling var keys=[....]; regedit.createKey(keys, function(err) {...});

the array keys is empty, why did the createKey function empty the array?

kessler commented 9 years ago

At some point the code empties the array when its being fed it to the stream. While its against normal best practices (such as defensive programming and such) I opted not to copy the array immediately since at times we are talking about very long arrays.

In this particular we rely on the client (i.e you) to use defensive programming.

Will update the documentation about this.

BilalBoulifa commented 9 years ago

ok, for my case I want to keep the keys after the creation so I cloned the array before.

Thank you for your explanation.