Skip to content

Commit

Permalink
Clone document on addStatic.
Browse files Browse the repository at this point in the history
  • Loading branch information
aljones15 committed May 29, 2024
1 parent 9ef1abd commit 8818a4b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# jsonld-document-loader

## 2.0.1 -

### Changed
- addStatic deep clones documents to avoid mutation.

## 2.0.0 - 2023-02-06

### Changed
Expand Down
5 changes: 3 additions & 2 deletions lib/JsonLdDocumentLoader.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*!
* Copyright (c) 2019-2023 Digital Bazaar, Inc. All rights reserved.
* Copyright (c) 2019-2024 Digital Bazaar, Inc. All rights reserved.
*/
import {klona} from 'klona';

export class JsonLdDocumentLoader {
constructor() {
Expand All @@ -15,7 +16,7 @@ export class JsonLdDocumentLoader {
if(!_isObject(document)) {
throw new TypeError('The second parameter (document) must be an object.');
}
this.documents.set(url, document);
this.documents.set(url, klona(document));
}

/**
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,8 @@
},
"engines": {
"node": ">=16"
},
"dependencies": {
"klona": "^2.0.6"
}
}

0 comments on commit 8818a4b

Please sign in to comment.