2015-10-01 22:56:47 -07:00
|
|
|
'use strict';
|
|
|
|
|
2015-10-19 16:19:43 -07:00
|
|
|
let constants = require('./constants');
|
2015-10-07 17:08:19 -07:00
|
|
|
let util = require('./util');
|
2015-10-01 22:56:47 -07:00
|
|
|
|
2015-10-19 12:06:47 -07:00
|
|
|
module.exports = {
|
|
|
|
create,
|
|
|
|
};
|
2015-10-01 22:56:47 -07:00
|
|
|
|
2015-10-19 12:06:47 -07:00
|
|
|
class List {}
|
2015-10-01 22:56:47 -07:00
|
|
|
|
2015-10-19 16:19:43 -07:00
|
|
|
util.createMethods(List.prototype, constants.propTypes.LIST, [
|
2015-10-01 22:56:47 -07:00
|
|
|
'pop',
|
|
|
|
'shift',
|
|
|
|
'push',
|
|
|
|
'unshift',
|
|
|
|
'splice',
|
2015-10-19 12:06:47 -07:00
|
|
|
], true);
|
2015-10-01 22:56:47 -07:00
|
|
|
|
|
|
|
function create(realmId, info) {
|
2015-10-19 17:43:51 -07:00
|
|
|
let meta = util.createList(List.prototype, realmId, info, true);
|
|
|
|
let list = Object.create(meta);
|
|
|
|
|
2015-10-20 00:52:38 -07:00
|
|
|
// This will make attempts at assigning to out-of-bounds indices throw an exception.
|
2015-10-19 17:43:51 -07:00
|
|
|
Object.preventExtensions(list);
|
|
|
|
|
|
|
|
return list;
|
2015-10-01 22:56:47 -07:00
|
|
|
}
|