File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed
Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 55
66- Feat: implement support for trailing commas in matrices (#3154 , #2968 ).
77 Thanks @dvd101x .
8+ - Fix: ` PartitionedMap ` and ` ObjectWrappingMap ` missing a property
9+ ` Symbol.iterator ` , causing problems when trying ` new Map(scope) ` . See
10+ https://github.com/josdejong/mathjs/discussions/3156#discussioncomment-8516994
811- Docs: describe method ` getAllAsMap ` in the Parser docs (#3158 , #3157 ).
912 Thanks @dvd101x .
1013
Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ import { isObject } from './is.js'
1212export class ObjectWrappingMap {
1313 constructor ( object ) {
1414 this . wrappedObject = object
15+
16+ this [ Symbol . iterator ] = this . entries
1517 }
1618
1719 keys ( ) {
@@ -80,6 +82,8 @@ export class PartitionedMap {
8082 this . a = a
8183 this . b = b
8284 this . bKeys = bKeys
85+
86+ this [ Symbol . iterator ] = this . entries
8387 }
8488
8589 get ( key ) {
Original file line number Diff line number Diff line change @@ -110,6 +110,10 @@ describe('maps', function () {
110110 const innerObject = toObject ( map )
111111 assert . strictEqual ( innerObject , obj )
112112
113+ // Create a new Map
114+ const copy = new Map ( map )
115+ assert . deepStrictEqual ( [ ...copy . keys ( ) ] , [ ...map . keys ( ) ] )
116+
113117 // clear
114118 map . clear ( )
115119 assert . deepStrictEqual ( [ ...map . keys ( ) ] , [ ] )
@@ -214,6 +218,16 @@ describe('maps', function () {
214218 assert . deepStrictEqual ( it . next ( ) , { done : true , value : undefined } )
215219 } )
216220
221+ it ( 'copy' , function ( ) {
222+ const { a, b, p } = createPartitionedMap ( [ 'b' ] )
223+ p
224+ . set ( 'a' , 2 )
225+ . set ( 'b' , 3 )
226+
227+ const copy = new Map ( p )
228+ assert . deepStrictEqual ( [ ...copy . keys ( ) ] , [ ...p . keys ( ) ] )
229+ } )
230+
217231 it ( 'size' , function ( ) {
218232 const { p } = createPartitionedMap ( [ 'b' ] )
219233 p . set ( 'a' , 2 )
You can’t perform that action at this time.
0 commit comments