mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-05-20 22:20:53 +02:00
32 lines
590 B
JavaScript
Vendored
32 lines
590 B
JavaScript
Vendored
// Original component by Cretu Eusebiu
|
|
// https://github.com/cretueusebiu/vform
|
|
|
|
/**
|
|
* Deep copy the given object.
|
|
*
|
|
* @param {Object} obj
|
|
* @return {Object}
|
|
*/
|
|
export function deepCopy (obj) {
|
|
if (obj === null || typeof obj !== 'object') {
|
|
return obj
|
|
}
|
|
|
|
const copy = Array.isArray(obj) ? [] : {}
|
|
|
|
Object.keys(obj).forEach(key => {
|
|
copy[key] = deepCopy(obj[key])
|
|
})
|
|
|
|
return copy
|
|
}
|
|
|
|
/**
|
|
* If the given value is not an array, wrap it in one.
|
|
*
|
|
* @param {Any} value
|
|
* @return {Array}
|
|
*/
|
|
export function arrayWrap (value) {
|
|
return Array.isArray(value) ? value : [value]
|
|
} |