Skip to content

Commit

Permalink
Reliably test Long.isLong (just like with ByteBuffers)
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodeIO committed Sep 26, 2015
1 parent 38fae64 commit 0ecc430
Show file tree
Hide file tree
Showing 10 changed files with 935 additions and 898 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "long",
"version": "2.2.5",
"version": "2.3.0",
"author": "Daniel Wirtz <[email protected]>",
"description": "A Long class for representing a 64 bit two's-complement integer value.",
"main": "dist/Long.js",
Expand Down
18 changes: 16 additions & 2 deletions dist/Long.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,29 @@
// Common constant values ZERO, ONE, NEG_ONE, etc. are defined below the from*
// methods on which they depend.

/**
* An indicator used to reliably determine if an object is a Long or not.
* @type {boolean}
* @const
* @expose
* @private
*/
Long.__isLong__;

Object.defineProperty(Long.prototype, "__isLong__", {
value: true,
enumerable: false,
configurable: false
});

/**
* Tests if the specified object is a Long.
* @param {*} obj Object
* @returns {boolean}
* @expose
*/
Long.isLong = function(obj) {
return (obj && obj instanceof Long) === true;
return (obj && obj["__isLong__"]) === true;
};

/**
Expand Down Expand Up @@ -944,5 +959,4 @@
};

return Long;

});
32 changes: 16 additions & 16 deletions dist/Long.min.js

Large diffs are not rendered by default.

Binary file modified dist/Long.min.js.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions dist/Long.min.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "long",
"version": "2.2.5",
"version": "2.3.0",
"author": "Daniel Wirtz <[email protected]>",
"description": "A Long class for representing a 64-bit two's-complement integer value.",
"main": "dist/Long.js",
Expand Down
2 changes: 1 addition & 1 deletion scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var scope = {};
console.log("Building Long with scope", JSON.stringify(scope, null, 2));
fs.writeFileSync(
path.join(distDir, "Long.js"),
MetaScript.transform(fs.readFileSync(filename = path.join(srcDir, "Long.js")), filename, scope, srcDir)
MetaScript.transform(fs.readFileSync(filename = path.join(srcDir, "wrap.js")), filename, scope, srcDir)
);

// Update bower.json
Expand Down
Loading

0 comments on commit 0ecc430

Please sign in to comment.