mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-10-13 06:51:29 +07:00
Improve code quality and write tests
This commit is contained in:
29
node_modules/regexp-tree/dist/utils/clone.js
generated
vendored
Normal file
29
node_modules/regexp-tree/dist/utils/clone.js
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
* Copyright (c) 2017-present Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Performs a deep copy of an simple object.
|
||||
* Only handles scalar values, arrays and objects.
|
||||
*
|
||||
* @param obj Object
|
||||
*/
|
||||
|
||||
module.exports = function clone(obj) {
|
||||
if (obj === null || typeof obj !== 'object') {
|
||||
return obj;
|
||||
}
|
||||
var res = void 0;
|
||||
if (Array.isArray(obj)) {
|
||||
res = [];
|
||||
} else {
|
||||
res = {};
|
||||
}
|
||||
for (var i in obj) {
|
||||
res[i] = clone(obj[i]);
|
||||
}
|
||||
return res;
|
||||
};
|
Reference in New Issue
Block a user