Skip to content

Commit

Permalink
fix(copy): improve copy function so that it creates a new dictionary …
Browse files Browse the repository at this point in the history
…with no prototype
  • Loading branch information
djcsdy committed Mar 19, 2020
1 parent fb95175 commit 0180549
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {Dictionary, Key, ReadonlyDictionary} from "dictionary-types";

/** Creates a shallow copy of the specified dictionary. */
export function copy<T, K extends Key, L extends K = K>(dictionary: ReadonlyDictionary<T, K>): Dictionary<T, L> {
return {...dictionary};
return Object.assign(Object.create(null), dictionary);
}

// @ts-ignore duplicate identifier: These overrides constitute the exported declaration, the implementation is below.
Expand Down

0 comments on commit 0180549

Please sign in to comment.