Permalink
Browse files

feature es5 and es6 support check

  • Loading branch information...
1 parent 6987dd5 commit fa5b7904a8671b58a52dffb56438df84fd299b95 Julien Polo committed May 18, 2012
Showing with 32 additions and 33 deletions.
  1. +15 −31 es.ext.js
  2. +16 −1 module.js
  3. +1 −1 spec/_base.js
View
@@ -811,52 +811,36 @@
}, false);
if (type !== Object) {
- Object.defineProperties(type.prototype, {
- __compare__: {
- value: function __compare__(other) {
- var
- valueSelf = +this,
- valueOther = +other;
- return (valueSelf === valueOther) ?
- 0:
- (valueSelf < valueOther ? 1 : -1);
- },
- enumerable: false,
- writable: true
+ shim(type, {
+ __compare__: function __compare__(other) {
+ var
+ valueSelf = +this,
+ valueOther = +other;
+ return (valueSelf === valueOther) ?
+ 0:
+ (valueSelf < valueOther ? 1 : -1);
},
- __hash__: {
- value: function __hash__() {
- return toString(this);
- },
- enumerable: false,
- writable: true
+ __hash__: function __hash__() {
+ return toString(this);
},
/**
* Return a copy of the scalar
*
* @return {*}
*/
- clone: {
- value: function clone(isDeep) {
- return this;
- },
- enumerable: false,
- writable: true
+ clone: function clone(isDeep) {
+ return this;
},
/**
* @return {boolean}
*/
- isEqual: {
- value: function isEqual(anyOtherValue) {
- return (this === anyOtherValue);
- },
- enumerable: false,
- writable: true
+ isEqual: function isEqual(anyOtherValue) {
+ return (this === anyOtherValue);
}
- });
+ }, true);
}
});
}));
View
@@ -642,6 +642,19 @@
}
});
+ /**
+ * @param {Function} fn
+ * @return {boolean}
+ */
+ def_("isNative", {
+ value: function isNative(fn) {
+ return (
+ typeof fn === "function" &&
+ ("" + fn).indexOf('[native code]') >= 0
+ );
+ }
+ });
+
/**
* Add a new feature test
*
@@ -733,6 +746,8 @@
}
return false;
}({})));
+ add("es5", $module.test("Object.defineProperty"));
+ add("es6", $module.isNative(global.Set));
add("Error#lineNumber", 'lineNumber' in new Error());
add("Error#stack", 'stack' in new Error());
}($module.add, $module.isHostType));
@@ -884,7 +899,7 @@
//engine
Env.engine = (function () {
- if (!!g.process) {
+ if (feature_("process")) {
return "node";
} else if (typeof window !== "undefined") {
return "browser";
View
@@ -35,7 +35,7 @@ define("stj/spec/_base", [], function () {
var actual = this.actual;
return (
typeof actual === "function" &&
- ("" + this.actual).indexOf('[native code]') >= 0
+ ("" + actual).indexOf('[native code]') >= 0
);
}
});

0 comments on commit fa5b790

Please sign in to comment.