Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('test null object', function () {
let result = lang.overwrite(
{
x: 1
},
null
);
assert.equal(result.x, 1);
result = lang.overwrite(
{
x: 1
},
undefined
);
assert.equal(result.x, 1);
result = lang.overwrite(
{
x: 1
},
false
);
assert.equal(result.x, 1);
});
it('test deep overwrite', function () {
let result = lang.overwrite(
{
level1: {
x: 1
}
},
{
level1: {
y: 3
}
}
);
assert.equal(result.level1.y, 3);
result = lang.overwrite(
{
level1: {
it('test fields', function () {
let result = lang.overwrite(
{
x: 1
},
{
x: 2
},
['x']
);
assert.equal(result.x, 2);
result = lang.overwrite(
{
x: 1
},
{
x: 2
it('test null object', function () {
let result = lang.overwrite(
{
x: 1
},
null
);
assert.equal(result.x, 1);
result = lang.overwrite(
{
x: 1
},
undefined
);
assert.equal(result.x, 1);
result = lang.overwrite(
it('test deep overwrite', function () {
let result = lang.overwrite(
{
level1: {
x: 1
}
},
{
level1: {
y: 3
}
}
);
assert.equal(result.level1.y, 3);
result = lang.overwrite(
{
level1: {
x: 1
}
},
{
level1: {
x: 2
}
}
);
assert.equal(result.level1.x, 2);
});
it('test fields', function () {
let result = lang.overwrite(
{
x: 1
},
{
x: 2
},
['x']
);
assert.equal(result.x, 2);
result = lang.overwrite(
{
x: 1
},
{
x: 2
},
['y']
);
assert.equal(result.x, 1);
});
{
x: 1
},
null
);
assert.equal(result.x, 1);
result = lang.overwrite(
{
x: 1
},
undefined
);
assert.equal(result.x, 1);
result = lang.overwrite(
{
x: 1
},
false
);
assert.equal(result.x, 1);
});
assert.throws(function () {
lang.overwrite(
'abcde',
{
0: 'f'
}
);
});
});