diff src/implab/safe.js @ 3:00779cb63b12

formatting
author cin
date Tue, 06 Jun 2017 19:45:32 +0300
parents fc2517695ee1
children 9c0943c68a90
line wrap: on
line diff
--- a/src/implab/safe.js	Fri Jun 02 19:28:20 2017 +0300
+++ b/src/implab/safe.js	Tue Jun 06 19:45:32 2017 +0300
@@ -1,84 +1,11 @@
 define([],
 
     function () {
-        var id = 0,
-            OID_FIELD = "__core_safe_oid_field",
-            _create, _defineProperty, _keys;
-
-        if (!Object.keys) {
-            _defineProperty = function (obj, prop, d) {
-                if (!d)
-                    throw new Error("Invalid descriptor");
-                obj[prop] = d.value;
-            };
-        } else {
-            _defineProperty = Object.defineProperty;
-        }
-
-        if (!Object.create) {
-            var tctor = function () {};
-            _create = function (proto) {
-                if (arguments.length > 1)
-                    throw new Error("The two arguments for isn't supported");
-
-                tctor.prototype = proto;
-                return new tctor();
-            };
-        } else {
-            _create = Object.create;
-        }
-
-        if (!Object.keys) {
-            // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys#Polyfill
-            _keys = (function () {
-                'use strict';
-                var hasOwnProperty = Object.prototype.hasOwnProperty,
-                    hasDontEnumBug = !({
-                        toString: null
-                    }).propertyIsEnumerable('toString'),
-                    dontEnums = [
-                        'toString',
-                        'toLocaleString',
-                        'valueOf',
-                        'hasOwnProperty',
-                        'isPrototypeOf',
-                        'propertyIsEnumerable',
-                        'constructor'
-                    ],
-                    dontEnumsLength = dontEnums.length;
-
-                return function (obj) {
-                    if (typeof obj !== 'object' && (typeof obj !== 'function' || obj === null)) {
-                        throw new TypeError('Object.keys called on non-object');
-                    }
-
-                    var result = [],
-                        prop, i;
-
-                    for (prop in obj) {
-                        if (prop != OID_FIELD && hasOwnProperty.call(obj, prop)) {
-                            result.push(prop);
-                        }
-                    }
-
-                    if (hasDontEnumBug) {
-                        for (i = 0; i < dontEnumsLength; i++) {
-                            if (hasOwnProperty.call(obj, dontEnums[i])) {
-                                result.push(dontEnums[i]);
-                            }
-                        }
-                    }
-                    return result;
-                };
-            }());
-        } else {
+        var _create = Object.create,
             _keys = Object.keys;
-        }
 
         var safe = null;
         safe = {
-            OID_FIELD: OID_FIELD,
-
             argumentNotNull: function (arg, name) {
                 if (arg === null || arg === undefined)
                     throw new Error("The argument " + name + " can't be null or undefined");
@@ -162,14 +89,6 @@
                 }
             },
 
-            oid: function (obj) {
-                return this.isPrimitive(obj) ? undefined : obj[OID_FIELD] ||
-                    (_defineProperty(obj, OID_FIELD, {
-                        value: ++id,
-                        enumerable: false
-                    }) && id);
-            },
-
             /**
              * Копирует свойства одного объекта в другой.
              * 
@@ -219,7 +138,11 @@
                 return dest;
             },
 
-            create: _create,
+            create: function () {
+                if (console && console.warn)
+                    console.warn("implab/safe::create is deprecated use Object.create instead");
+                _create.apply(this, arguments);
+            },
 
             delegate: function (target, method) {
                 if (!(method instanceof Function)) {
@@ -344,7 +267,7 @@
                         return cb ? cb(sequence[0]) : sequence[0];
                     }
                 }
-                
+
                 if (err)
                     return err(new Error("The sequence is required"));
                 else