[Pkg-javascript-commits] [node-clone] 01/03: New upstream version 2.1.1

Julien Puydt julien.puydt at laposte.net
Sat Mar 25 08:40:49 UTC 2017


This is an automated email from the git hooks/post-receive script.

jpuydt-guest pushed a commit to branch master
in repository node-clone.

commit 7c83af2400652e4b5a8b493e7642c5fba90c7fd5
Author: Julien Puydt <julien.puydt at laposte.net>
Date:   Sat Mar 25 09:39:09 2017 +0100

    New upstream version 2.1.1
---
 README.md    | 19 ++++++++++++-------
 clone.js     | 40 +++++++++++++++++-----------------------
 package.json |  5 +++--
 3 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/README.md b/README.md
index dc37936..c21ba16 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,6 @@
 # clone
 
-[![build status](https://secure.travis-ci.org/pvorb/node-clone.svg)](http://travis-ci.org/pvorb/node-clone)
-
-[![info badge](https://nodei.co/npm/clone.svg?downloads=true&downloadRank=true&stars=true)](http://npm-stat.com/charts.html?package=clone)
+[![build status](https://secure.travis-ci.org/pvorb/clone.svg)](http://travis-ci.org/pvorb/clone) [![downloads](https://img.shields.io/npm/dt/clone.svg)](http://npm-stat.com/charts.html?package=clone)
 
 offers foolproof _deep cloning_ of objects, arrays, numbers, strings, maps,
 sets, promises, etc. in JavaScript.
@@ -100,6 +98,13 @@ So, `b.myself` points to `b`, not `a`. Neat!
 
 ## Changelog
 
+### v2.1.1
+
+#### 2017-03-09
+
+  - Fix build badge in README
+  - Add support for cloning Maps and Sets on Internet Explorer
+
 ### v2.1.0
 
 #### 2016-11-22
@@ -141,19 +146,19 @@ So, `b.myself` points to `b`, not `a`. Neat!
 
 Some special objects like a socket or `process.stdout`/`stderr` are known to not
 be cloneable. If you find other objects that cannot be cloned, please [open an
-issue](https://github.com/pvorb/node-clone/issues/new).
+issue](https://github.com/pvorb/clone/issues/new).
 
 
 ## Bugs and Issues
 
 If you encounter any bugs or issues, feel free to [open an issue at
-github](https://github.com/pvorb/node-clone/issues) or send me an email to
+github](https://github.com/pvorb/clone/issues) or send me an email to
 <paul at vorba.ch>. I also always like to hear from you, if you’re using my code.
 
 ## License
 
-Copyright © 2011-2016 [Paul Vorbach](http://paul.vorba.ch/) and
-[contributors](https://github.com/pvorb/node-clone/graphs/contributors).
+Copyright © 2011-2016 [Paul Vorbach](https://paul.vorba.ch/) and
+[contributors](https://github.com/pvorb/clone/graphs/contributors).
 
 Permission is hereby granted, free of charge, to any person obtaining a copy of
 this software and associated documentation files (the “Software”), to deal in
diff --git a/clone.js b/clone.js
index c3bf162..80d0c76 100644
--- a/clone.js
+++ b/clone.js
@@ -1,6 +1,10 @@
 var clone = (function() {
 'use strict';
 
+function _instanceof(obj, type) {
+  return type != null && obj instanceof type;
+}
+
 var nativeMap;
 try {
   nativeMap = Map;
@@ -80,11 +84,11 @@ function clone(parent, circular, depth, prototype, includeNonEnumerable) {
       return parent;
     }
 
-    if (parent instanceof nativeMap) {
+    if (_instanceof(parent, nativeMap)) {
       child = new nativeMap();
-    } else if (parent instanceof nativeSet) {
+    } else if (_instanceof(parent, nativeSet)) {
       child = new nativeSet();
-    } else if (parent instanceof nativePromise) {
+    } else if (_instanceof(parent, nativePromise)) {
       child = new nativePromise(function (resolve, reject) {
         parent.then(function(value) {
           resolve(_clone(value, depth - 1));
@@ -103,7 +107,7 @@ function clone(parent, circular, depth, prototype, includeNonEnumerable) {
       child = new Buffer(parent.length);
       parent.copy(child);
       return child;
-    } else if (parent instanceof Error) {
+    } else if (_instanceof(parent, Error)) {
       child = Object.create(parent);
     } else {
       if (typeof prototype == 'undefined') {
@@ -126,28 +130,18 @@ function clone(parent, circular, depth, prototype, includeNonEnumerable) {
       allChildren.push(child);
     }
 
-    if (parent instanceof nativeMap) {
-      var keyIterator = parent.keys();
-      while(true) {
-        var next = keyIterator.next();
-        if (next.done) {
-          break;
-        }
-        var keyChild = _clone(next.value, depth - 1);
-        var valueChild = _clone(parent.get(next.value), depth - 1);
+    if (_instanceof(parent, nativeMap)) {
+      parent.forEach(function(value, key) {
+        var keyChild = _clone(key, depth - 1);
+        var valueChild = _clone(value, depth - 1);
         child.set(keyChild, valueChild);
-      }
+      });
     }
-    if (parent instanceof nativeSet) {
-      var iterator = parent.keys();
-      while(true) {
-        var next = iterator.next();
-        if (next.done) {
-          break;
-        }
-        var entryChild = _clone(next.value, depth - 1);
+    if (_instanceof(parent, nativeSet)) {
+      parent.forEach(function(value) {
+        var entryChild = _clone(value, depth - 1);
         child.add(entryChild);
-      }
+      });
     }
 
     for (var i in parent) {
diff --git a/package.json b/package.json
index 0584117..ce8d7e3 100644
--- a/package.json
+++ b/package.json
@@ -8,7 +8,7 @@
     "function",
     "date"
   ],
-  "version": "2.1.0",
+  "version": "2.1.1",
   "repository": {
     "type": "git",
     "url": "git://github.com/pvorb/node-clone.git"
@@ -38,7 +38,8 @@
     "fscherwi (https://fscherwi.github.io)",
     "rictic (https://github.com/rictic)",
     "Martin Jurča (https://github.com/jurca)",
-    "Misery Lee <miserylee at foxmail.com> (https://github.com/miserylee)"
+    "Misery Lee <miserylee at foxmail.com> (https://github.com/miserylee)",
+    "Clemens Wolff (https://github.com/c-w)"
   ],
   "license": "MIT",
   "engines": {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-clone.git



More information about the Pkg-javascript-commits mailing list