forked from josdejong/mathjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscope.js
More file actions
22 lines (21 loc) · 690 Bytes
/
Copy pathscope.js
File metadata and controls
22 lines (21 loc) · 690 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { ObjectWrappingMap, PartitionedMap } from './map.js'
/**
* Create a new scope which can access the parent scope,
* but does not affect it when written. This is suitable for variable definitions
* within a block node, or function definition.
*
* If parent scope has a createSubScope method, it delegates to that. Otherwise,
* creates an empty map, and copies the parent scope to it, adding in
* the remaining `args`.
*
* @param {Map} parentScope
* @param {Object} args
* @returns {PartitionedMap}
*/
export function createSubScope (parentScope, args) {
return new PartitionedMap(
parentScope,
new ObjectWrappingMap(args),
new Set(Object.keys(args))
)
}