fix(core): update

This commit is contained in:
Philipp Kunz 2020-10-05 11:13:17 +00:00
parent 2707542234
commit 176ac34504
2 changed files with 15 additions and 13 deletions

View File

@ -26,8 +26,8 @@ tap.test('should create a folded object', async () => {
}); });
tap.test('should enfold from object', async () => { tap.test('should enfold from object', async () => {
mySomeClass.enfoldFromObject({ thisis: 'test2' }); const mySomeClass2 = SomeClass.enfoldFromObject({ thisis: 'test2' });
expect(mySomeClass) expect(mySomeClass2)
.property('thisis') .property('thisis')
.to.equal('test2'); .to.equal('test2');
}); });

View File

@ -15,6 +15,19 @@ export class Smartjson {
return plugins.stableJson(objArg, optionsArg); return plugins.stableJson(objArg, optionsArg);
} }
/**
* enfolds data from an object
*/
public static enfoldFromObject(objectArg) {
const newInstance = new this();
for (const keyName in objectArg) {
if (newInstance.saveableProperties.indexOf(keyName) !== -1) {
newInstance[keyName] = objectArg[keyName];
}
}
return newInstance;
}
// ======== // ========
// INSTANCE // INSTANCE
// ======== // ========
@ -31,17 +44,6 @@ export class Smartjson {
} }
return newFoldedObject; return newFoldedObject;
} }
/**
* enfolds data from an object
*/
public enfoldFromObject(objectArg) {
for (const keyName in objectArg) {
if (this.saveableProperties.indexOf(keyName) !== -1) {
this[keyName] = objectArg[keyName];
}
}
}
} }
/** /**