Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async create(value: PreEntity): Promise {
if (value.id != null) {
if (this.pool[value.id] != null) {
throw new Error(
`The given id "${value.id}" already exists in memory pool.`
);
}
// @ts-ignore value.id exists
return this.set(value);
}
const newValue = updateAndRestore(value, { id: randomString() });
// @ts-ignore value.id exists
return this.set(newValue);
}