Skip to content

Commit

Permalink
Use 'instanceOf' to make the use of 'new' optional (#191)
Browse files Browse the repository at this point in the history
* Use 'instanceOf' to make the use of 'new' optional

* Should work as usual when used without new

* v1.4.2
  • Loading branch information
felquis authored and Valve committed Oct 3, 2016
1 parent 0a30285 commit cfe05db
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions fingerprint2.js
Expand Up @@ -54,6 +54,9 @@
};
}
var Fingerprint2 = function(options) {

if (!(this instanceof Fingerprint2)) return new Fingerprint2(options)

var defaultOptions = {
swfContainerId: "fingerprintjs2",
swfPath: "flash/compiled/FontList.swf",
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "fingerprintjs2",
"version": "1.4.1",
"version": "1.4.2",
"description": "Modern & flexible browser fingerprinting library",
"main": "dist/fingerprint2.min.js",
"devDependencies": {
Expand Down
6 changes: 6 additions & 0 deletions specs/specs.js
Expand Up @@ -43,6 +43,12 @@ describe("Fingerprint2", function () {
});
});

describe("without new keyword", function () {
it("creates a new instance of FP2", function () {
expect(Fingerprint2()).not.toBeNull();
});
})

describe("get", function () {
describe("default options", function () {
it("calculates fingerprint", function (done) {
Expand Down

0 comments on commit cfe05db

Please sign in to comment.