File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed
Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change 1+ var overload = require ( "./overload" )
2+ , Watchable = overload . Watchable
3+ , RePrototype = overload . RePrototype
4+
5+ exports . ReadOnly = ReadOnly = function ( obj , mask ) {
6+ var $this = Watchable ( function ( args ) {
7+ var v = mask
8+ && args . property in mask
9+ ? mask [ args . property ]
10+ : obj [ args . property ] ;
11+ if ( typeof ( v ) == "function" ) {
12+ return function ( ) { return v . apply ( obj , arguments ) }
13+ }
14+ return v ;
15+ } ) ;
16+ //only objects have prototypes
17+ if ( obj instanceof Object ) {
18+ RePrototype ( $this , Object . getPrototypeOf ( obj ) )
19+ }
20+ return $this ;
21+ }
22+ var noop = function ( ) { }
23+ ReadOnly . ArrayMask = {
24+ pop :function ( ) { return this [ this . length - 1 ] ; }
25+ , push :function ( ) { return this . length }
26+ , reverse :noop
27+ , shift :function ( ) { return this [ 0 ] ; }
28+ , sort :noop
29+ , splice :function ( ) { return [ ] ; }
30+ , unshift :function ( ) { return this . length }
31+ }
32+ ReadOnly . DateMask = {
33+ setDate :noop
34+ , setFullYear :noop
35+ , setHours :noop
36+ , setMilliseconds :noop
37+ , setMinutes :noop
38+ , setMonth :noop
39+ , setSeconds :noop
40+ , setTime :noop
41+ , setUTCDate :noop
42+ , setUTCFullYear :noop
43+ , setUTCHours :noop
44+ , setUTCMilliseconds :noop
45+ , setUTCMinutes :noop
46+ , setUTCMonth :noop
47+ , setUTCSeconds :noop
48+ , setYear :noop
49+ }
50+ ReadOnly . StringMask = { }
51+ delete noop ;
You can’t perform that action at this time.
0 commit comments