all files / montage/core/shim/ object.js

21.43% Statements 3/14
37.5% Branches 3/8
0% Functions 0/5
21.43% Lines 3/14
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62                                                                                                                     
/**
 * Defines standardized shims for the intrinsic `Object`.
 * @see {external:Object}
 * @module montage/core/shim/object
 */
 
/**
 * @external Object
 */
 
/**
 * Creates a new object that inherits prototypically directly from a given
 * prototype, optionally defining some properties.
 * @function external:Object.create
 * @param {Object} prototype the prototype to inherit, or
 * `null` for no prototype, which makes "__proto__" the only
 * special property name.
 * @param {Object} descriptor a property descriptor
 * @returns a new object inheriting from the given prototype and having
 * the given property descriptor.
 */
Iif (!Object.create) {
    Object._creator = function _ObjectCreator() {
        this.__proto__ = _ObjectCreator.prototype;
    };
    Object.create = function (o, properties) {
        this._creator.prototype = o || Object.prototype;
        //Still needs to add properties....
        return new this._creator;
    };
 
    Object.getPrototypeOf = function (o) {
        return o.__proto__;
    };
}
 
// These are used in montage.js to ascertain whether we can annotate
// objects with montage metadata.
 
// TODO documentation
Iif (!Object.isSealed) {
    Object.defineProperty(Object, "isSealed", {
        value: function () {
            return false;
        },
        writable: true,
        configurable: true
    });
}
 
// TODO documentation
Iif (!Object.seal) {
    Object.defineProperty(Object, "seal", {
        value: function (object) {
            return object;
        },
        writable: true,
        configurable: true
    });
}