mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 09:27:58 +01:00
Add 'javascript' module. Misc fixes along the way.
This commit is contained in:
@@ -767,18 +767,20 @@ const Util = Module("util", {
|
||||
/**
|
||||
* Array utility methods.
|
||||
*/
|
||||
Array: Class("Array", {
|
||||
Array: Class("Array", Array, {
|
||||
init: function (ary) {
|
||||
return {
|
||||
__proto__: ary,
|
||||
__iterator__: function () this.iteritems(),
|
||||
__noSuchMethod__: function (meth, args) {
|
||||
let res = (util.Array[meth] || Array[meth]).apply(null, [this.__proto__].concat(args));
|
||||
var res = util.Array[meth].apply(null, [this.__proto__].concat(args));
|
||||
|
||||
if (util.Array.isinstance(res))
|
||||
return util.Array(res);
|
||||
return res;
|
||||
},
|
||||
concat: function () [].concat.apply(this.__proto__, arguments),
|
||||
toString: function () this.__proto__.toString(),
|
||||
concat: function () this.__proto__.concat.apply(this.__proto__, arguments),
|
||||
map: function () this.__noSuchMethod__("map", Array.slice(arguments))
|
||||
};
|
||||
}
|
||||
@@ -787,8 +789,6 @@ const Util = Module("util", {
|
||||
return Object.prototype.toString.call(obj) == "[object Array]";
|
||||
},
|
||||
|
||||
toString: function () this.__proto__.toString(),
|
||||
|
||||
/**
|
||||
* Converts an array to an object. As in lisp, an assoc is an
|
||||
* array of key-value pairs, which maps directly to an object,
|
||||
@@ -864,7 +864,7 @@ const Util = Module("util", {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
})
|
||||
}),
|
||||
});
|
||||
|
||||
// vim: set fdm=marker sw=4 ts=4 et:
|
||||
|
||||
Reference in New Issue
Block a user