@common.js/mimic-function 5.0.0 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/index.js +7 -55
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  The [mimic-function](https://www.npmjs.com/package/mimic-function) package exported as CommonJS modules.
4
4
 
5
- Exported from [mimic-function@5.0.0](https://www.npmjs.com/package/mimic-function/v/5.0.0) using https://github.com/etienne-martin/common.js.
5
+ Exported from [mimic-function@5.0.1](https://www.npmjs.com/package/mimic-function/v/5.0.1) using https://github.com/etienne-martin/common.js.
package/index.js CHANGED
@@ -8,58 +8,6 @@ Object.defineProperty(exports, "default", {
8
8
  return mimicFunction;
9
9
  }
10
10
  });
11
- function _defineProperty(obj, key, value) {
12
- if (key in obj) {
13
- Object.defineProperty(obj, key, {
14
- value: value,
15
- enumerable: true,
16
- configurable: true,
17
- writable: true
18
- });
19
- } else {
20
- obj[key] = value;
21
- }
22
- return obj;
23
- }
24
- function _objectSpread(target) {
25
- for(var i = 1; i < arguments.length; i++){
26
- var source = arguments[i] != null ? arguments[i] : {};
27
- var ownKeys = Object.keys(source);
28
- if (typeof Object.getOwnPropertySymbols === "function") {
29
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
30
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
31
- }));
32
- }
33
- ownKeys.forEach(function(key) {
34
- _defineProperty(target, key, source[key]);
35
- });
36
- }
37
- return target;
38
- }
39
- function ownKeys(object, enumerableOnly) {
40
- var keys = Object.keys(object);
41
- if (Object.getOwnPropertySymbols) {
42
- var symbols = Object.getOwnPropertySymbols(object);
43
- if (enumerableOnly) {
44
- symbols = symbols.filter(function(sym) {
45
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
46
- });
47
- }
48
- keys.push.apply(keys, symbols);
49
- }
50
- return keys;
51
- }
52
- function _objectSpreadProps(target, source) {
53
- source = source != null ? source : {};
54
- if (Object.getOwnPropertyDescriptors) {
55
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
56
- } else {
57
- ownKeys(Object(source)).forEach(function(key) {
58
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
59
- });
60
- }
61
- return target;
62
- }
63
11
  var copyProperty = function(to, from, property, ignoreNonConfigurable) {
64
12
  // `Function#length` should reflect the parameters of `to` not `from` since we keep its body.
65
13
  // `Function#prototype` is non-writable and non-configurable so can never be modified.
@@ -103,9 +51,13 @@ var changeToString = function(to, from, name) {
103
51
  var newToString = wrappedToString.bind(null, withName, from.toString());
104
52
  // Ensure `to.toString.toString` is non-enumerable and has the same `same`
105
53
  Object.defineProperty(newToString, "name", toStringName);
106
- Object.defineProperty(to, "toString", _objectSpreadProps(_objectSpread({}, toStringDescriptor), {
107
- value: newToString
108
- }));
54
+ var writable = toStringDescriptor.writable, enumerable = toStringDescriptor.enumerable, configurable = toStringDescriptor.configurable; // We destructue to avoid a potential `get` descriptor.
55
+ Object.defineProperty(to, "toString", {
56
+ value: newToString,
57
+ writable: writable,
58
+ enumerable: enumerable,
59
+ configurable: configurable
60
+ });
109
61
  };
110
62
  function mimicFunction(to, from) {
111
63
  var ref = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, _ignoreNonConfigurable = ref.ignoreNonConfigurable, ignoreNonConfigurable = _ignoreNonConfigurable === void 0 ? false : _ignoreNonConfigurable;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@common.js/mimic-function",
3
- "version": "5.0.0",
3
+ "version": "5.0.1",
4
4
  "description": "mimic-function package exported as CommonJS modules",
5
5
  "license": "MIT",
6
6
  "repository": "etienne-martin/common.js",