1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-06 03:50:04 +02:00
Oinktube/node_modules/level-supports/test/cloneable.js
2022-07-15 11:08:01 -03:00

26 lines
795 B
JavaScript

'use strict'
var supports = require('..')
// Every object in a manifest must have a unique identity, to avoid accidental
// mutation. In supports() we only shallowly clone the manifest object itself
// and additionalMethods. If in the future we add more objects to manifests,
// this test will break and we'll know to start performing a deep clone.
module.exports = function cloneable (t, manifest) {
var copy = supports(manifest)
verifyUnique(t, 'manifest', manifest, copy)
}
function verifyUnique (t, path, a, b) {
if (isObject(a) && isObject(b)) {
t.ok(a !== b, path + ' has unique identity')
Object.keys(a).forEach(function (key) {
verifyUnique(t, path + '.' + key, a[key], b[key])
})
}
}
function isObject (o) {
return typeof o === 'object' && o !== null
}