mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-20 03:02:36 +03:00
31 lines
705 B
JavaScript
31 lines
705 B
JavaScript
|
/*
|
||
|
* Generics for Duktape binding in NetSurf
|
||
|
*
|
||
|
* The result of this *MUST* be setting a NetSurf object only.
|
||
|
*
|
||
|
* That object will then be absorbed into the global object as a hidden
|
||
|
* object which is used by the rest of the bindings.
|
||
|
*/
|
||
|
|
||
|
var NetSurf = {
|
||
|
/* The make-proxy call for list-type objects */
|
||
|
makeListProxy: function(inner) {
|
||
|
return new Proxy(inner, {
|
||
|
has: function(target, key) {
|
||
|
if (typeof key == 'number') {
|
||
|
return (key >= 0) && (key < target.length);
|
||
|
} else {
|
||
|
return key in target;
|
||
|
}
|
||
|
},
|
||
|
get: function(target, key) {
|
||
|
if (typeof key == 'number') {
|
||
|
return target.item(key);
|
||
|
} else {
|
||
|
return target[key];
|
||
|
}
|
||
|
},
|
||
|
});
|
||
|
},
|
||
|
};
|