@@ -3121,15 +3121,15 @@ var Record = function Record(defaultValues, name) {
3121
3121
}
3122
3122
this . _map = Map ( values ) ;
3123
3123
} ;
3124
- defaultValues = Sequence ( defaultValues ) ;
3124
+ var keys = Object . keys ( defaultValues ) ;
3125
3125
var RecordTypePrototype = RecordType . prototype = Object . create ( RecordPrototype ) ;
3126
3126
RecordTypePrototype . constructor = RecordType ;
3127
- RecordTypePrototype . _name = name ;
3127
+ name && ( RecordTypePrototype . _name = name ) ;
3128
3128
RecordTypePrototype . _defaultValues = defaultValues ;
3129
- var keys = Object . keys ( defaultValues ) ;
3130
- RecordType . prototype . length = keys . length ;
3131
- if ( Object . defineProperty ) {
3132
- defaultValues . forEach ( ( function ( _ , key ) {
3129
+ RecordTypePrototype . _keys = keys ;
3130
+ RecordTypePrototype . length = keys . length ;
3131
+ try {
3132
+ Sequence ( defaultValues ) . forEach ( ( function ( _ , key ) {
3133
3133
Object . defineProperty ( RecordType . prototype , key , {
3134
3134
get : function ( ) {
3135
3135
return this . get ( key ) ;
@@ -3140,22 +3140,22 @@ var Record = function Record(defaultValues, name) {
3140
3140
}
3141
3141
} ) ;
3142
3142
} ) ) ;
3143
- }
3143
+ } catch ( error ) { }
3144
3144
return RecordType ;
3145
3145
} ;
3146
3146
var $Record = Record ;
3147
3147
( $traceurRuntime . createClass ) ( Record , {
3148
3148
toString : function ( ) {
3149
- return this . __toString ( ( this . _name || 'Record' ) + ' {' , '}' ) ;
3149
+ return this . __toString ( this . _name + ' {' , '}' ) ;
3150
3150
} ,
3151
3151
has : function ( k ) {
3152
- return this . _defaultValues . has ( k ) ;
3152
+ return this . _defaultValues . hasOwnProperty ( k ) ;
3153
3153
} ,
3154
3154
get : function ( k , notSetValue ) {
3155
3155
if ( notSetValue !== undefined && ! this . has ( k ) ) {
3156
3156
return notSetValue ;
3157
3157
}
3158
- return this . _map . get ( k , this . _defaultValues . get ( k ) ) ;
3158
+ return this . _map . get ( k , this . _defaultValues [ k ] ) ;
3159
3159
} ,
3160
3160
clear : function ( ) {
3161
3161
if ( this . __ownerID ) {
@@ -3166,8 +3166,8 @@ var $Record = Record;
3166
3166
return $Record . _empty || ( $Record . _empty = makeRecord ( this , Map . empty ( ) ) ) ;
3167
3167
} ,
3168
3168
set : function ( k , v ) {
3169
- if ( k == null || ! this . has ( k ) ) {
3170
- return this ;
3169
+ if ( ! this . has ( k ) ) {
3170
+ throw new Error ( 'Cannot set unknown key "' + k + '" on ' + this . _name ) ;
3171
3171
}
3172
3172
var newMap = this . _map . set ( k , v ) ;
3173
3173
if ( this . __ownerID || newMap === this . _map ) {
@@ -3201,9 +3201,9 @@ var $Record = Record;
3201
3201
return this . _map . __iterator ( type , reverse ) ;
3202
3202
} ,
3203
3203
__iterate : function ( fn , reverse ) {
3204
- var record = this ;
3205
- return this . _defaultValues . map ( ( function ( _ , k ) {
3206
- return record . get ( k ) ;
3204
+ var $__0 = this ;
3205
+ return Sequence ( this . _defaultValues ) . map ( ( function ( _ , k ) {
3206
+ return $__0 . get ( k ) ;
3207
3207
} ) ) . __iterate ( fn , reverse ) ;
3208
3208
} ,
3209
3209
__ensureOwner : function ( ownerID ) {
@@ -3220,6 +3220,7 @@ var $Record = Record;
3220
3220
}
3221
3221
} , { } , Sequence ) ;
3222
3222
var RecordPrototype = Record . prototype ;
3223
+ RecordPrototype . _name = 'Record' ;
3223
3224
RecordPrototype [ DELETE ] = RecordPrototype . remove ;
3224
3225
RecordPrototype . merge = MapPrototype . merge ;
3225
3226
RecordPrototype . mergeWith = MapPrototype . mergeWith ;
0 commit comments