Skip to content

Commit ebf6575

Browse files
committed
Use Map to internally represent contexts.
1 parent 1f6f9da commit ebf6575

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# jsonld-signatures ChangeLog
22

3+
## 9.1.1 - 2021-06-xx
4+
5+
### Fixed
6+
- Use `Map` to internally represent contexts instead of an object. This
7+
optimizes better w/ v8.
8+
39
## 9.1.0 - 2021-06-29
410

511
### Changed

lib/contexts.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/*
2-
* Copyright (c) 2017-2018 Digital Bazaar, Inc. All rights reserved.
2+
* Copyright (c) 2017-2021 Digital Bazaar, Inc. All rights reserved.
33
*/
44
'use strict';
55

66
const constants = require('./constants');
77
const {contexts: securityContexts} = require('security-context');
88

9-
module.exports = {
10-
[constants.SECURITY_CONTEXT_V1_URL]:
11-
securityContexts.get(constants.SECURITY_CONTEXT_V1_URL),
12-
[constants.SECURITY_CONTEXT_V2_URL]:
13-
securityContexts.get(constants.SECURITY_CONTEXT_V2_URL)
14-
};
9+
module.exports = new Map([
10+
[constants.SECURITY_CONTEXT_V1_URL,
11+
securityContexts.get(constants.SECURITY_CONTEXT_V1_URL)],
12+
[constants.SECURITY_CONTEXT_V2_URL,
13+
securityContexts.get(constants.SECURITY_CONTEXT_V2_URL)]
14+
]);

lib/documentLoader.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* Copyright (c) 2018 Digital Bazaar, Inc. All rights reserved.
2+
* Copyright (c) 2018-2021 Digital Bazaar, Inc. All rights reserved.
33
*/
44
'use strict';
55

@@ -36,7 +36,7 @@ api.extendContextLoader = documentLoader => {
3636
* url then fetches a jsonld document.
3737
*/
3838
return async url => {
39-
const context = contexts[url];
39+
const context = contexts.get(url);
4040
if(context !== undefined) {
4141
return {
4242
contextUrl: null,

0 commit comments

Comments
 (0)