clone-help-test01 1.0.0 → 1.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.
@@ -0,0 +1,8 @@
1
+ module.exports = {
2
+ input: './src/clone.js',
3
+ output: {
4
+ file: 'dist/index.cjs.js',
5
+ format: 'cjs',
6
+ name: '_'
7
+ }
8
+ }
@@ -0,0 +1,8 @@
1
+ module.exports = {
2
+ input: './src/clone.js',
3
+ output: {
4
+ file: 'dist/index.ems.js',
5
+ format: 'esm',
6
+ name: '_'
7
+ }
8
+ }
@@ -0,0 +1,8 @@
1
+ module.exports = {
2
+ input: './src/clone.js',
3
+ output: {
4
+ file: 'dist/index.umd.js',
5
+ format: 'umd',
6
+ name: '_'
7
+ }
8
+ }
@@ -0,0 +1,30 @@
1
+ 'use strict';
2
+
3
+ function type(data) {
4
+ return Object.prototype.toString.call(data).slice(8, -1).toLowerCase();
5
+ }
6
+
7
+
8
+ function clone(source) {
9
+ const t = type(source);
10
+ if (t !== 'object' && t !== 'array') {
11
+ return source;
12
+ }
13
+ let target;
14
+ if (t === 'object') {
15
+ target = {};
16
+ for (const i in source) {
17
+ if (source.hasOwnProperty(i)) {
18
+ target[i] = clone(source[i]);
19
+ }
20
+ }
21
+ } else {
22
+ target = [];
23
+ for (let i = 0; i < source.length; i++) {
24
+ target[i] = clone(target[i]);
25
+ }
26
+ }
27
+ return target;
28
+ }
29
+
30
+ exports.clone = clone;
@@ -0,0 +1,28 @@
1
+ function type(data) {
2
+ return Object.prototype.toString.call(data).slice(8, -1).toLowerCase();
3
+ }
4
+
5
+
6
+ function clone(source) {
7
+ const t = type(source);
8
+ if (t !== 'object' && t !== 'array') {
9
+ return source;
10
+ }
11
+ let target;
12
+ if (t === 'object') {
13
+ target = {};
14
+ for (const i in source) {
15
+ if (source.hasOwnProperty(i)) {
16
+ target[i] = clone(source[i]);
17
+ }
18
+ }
19
+ } else {
20
+ target = [];
21
+ for (let i = 0; i < source.length; i++) {
22
+ target[i] = clone(target[i]);
23
+ }
24
+ }
25
+ return target;
26
+ }
27
+
28
+ export { clone };
@@ -0,0 +1,36 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global._ = {}));
5
+ })(this, (function (exports) { 'use strict';
6
+
7
+ function type(data) {
8
+ return Object.prototype.toString.call(data).slice(8, -1).toLowerCase();
9
+ }
10
+
11
+
12
+ function clone(source) {
13
+ const t = type(source);
14
+ if (t !== 'object' && t !== 'array') {
15
+ return source;
16
+ }
17
+ let target;
18
+ if (t === 'object') {
19
+ target = {};
20
+ for (const i in source) {
21
+ if (source.hasOwnProperty(i)) {
22
+ target[i] = clone(source[i]);
23
+ }
24
+ }
25
+ } else {
26
+ target = [];
27
+ for (let i = 0; i < source.length; i++) {
28
+ target[i] = clone(target[i]);
29
+ }
30
+ }
31
+ return target;
32
+ }
33
+
34
+ exports.clone = clone;
35
+
36
+ }));
package/package.json CHANGED
@@ -1,15 +1,19 @@
1
1
  {
2
2
  "name": "clone-help-test01",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "",
5
5
  "main": "clone.js",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1",
8
- "build": "rollup -c"
8
+ "build": "npm run build:esm && npm run build:cjs &&npm run build:umd",
9
+ "build:esm": "rollup -c config/rollup.config.esm.js",
10
+ "build:cjs": "rollup -c config/rollup.config.cjs.js",
11
+ "build:umd": "rollup -c config/rollup.config.umd.js"
9
12
  },
10
13
  "author": "",
11
14
  "license": "ISC",
12
15
  "dependencies": {
16
+ "clone-help-test01": "^1.0.0",
13
17
  "rollup": "^4.59.0"
14
18
  }
15
19
  }
package/src/index.html CHANGED
@@ -5,7 +5,7 @@
5
5
  <meta charset="UTF-8">
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
7
  <title>Document</title>
8
- <script src="../dist/bundle.js"></script>
8
+ <script src="../node_modules/clone-help-test01//dist/bundle.js"></script>
9
9
  </head>
10
10
 
11
11
  <body>