Comparing version 2.0.0 to 2.0.1
@@ -23,6 +23,7 @@ "use strict"; | ||
length = str.length, | ||
max = charset.length, | ||
i, char; | ||
for (i = 0; i < length; i++) { | ||
char = str[i]; | ||
res += byChar[char] * Math.pow(62, (length - i - 1)); | ||
res += byChar[char] * Math.pow(max, (length - i - 1)); | ||
} | ||
@@ -29,0 +30,0 @@ return res; |
@@ -11,11 +11,11 @@ { | ||
"license": "MIT", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/andrew/base62.js.git" | ||
"url": "git+https://github.com/base62/base62.js.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/andrew/base62.js/issues" | ||
"url": "https://github.com/base62/base62.js/issues" | ||
}, | ||
"homepage": "https://github.com/andrew/base62.js", | ||
"homepage": "https://github.com/base62/base62.js", | ||
"main": "./lib/legacy.js", | ||
@@ -30,4 +30,4 @@ "engines": { | ||
"devDependencies": { | ||
"mocha": "~5.1.0" | ||
"mocha": "~6.0.2" | ||
} | ||
} |
# [Base62.js](http://libraries.io/npm/base62) | ||
[![build status](https://secure.travis-ci.org/andrew/base62.js.svg)](http://travis-ci.org/andrew/base62.js) | ||
[![build status](https://secure.travis-ci.org/base62/base62.js.svg)](http://travis-ci.org/base62/base62.js) | ||
[![npm version](https://badge.fury.io/js/base62.svg)](http://badge.fury.io/js/base62) | ||
[![devDependency Status](https://david-dm.org/andrew/base62.js/dev-status.svg?theme=shields.io)](https://david-dm.org/andrew/base62.js#info=devDependencies) | ||
[![Gitter chat](http://img.shields.io/badge/gitter-andrew/base62.js-brightgreen.svg)](https://gitter.im/andrew/base62.js) | ||
[![devDependency Status](https://david-dm.org/base62/base62.js/dev-status.svg?theme=shields.io)](https://david-dm.org/base62/base62.js#info=devDependencies) | ||
[![Gitter chat](http://img.shields.io/badge/gitter-base62/base62.js-brightgreen.svg)](https://gitter.im/base62/base62.js) | ||
@@ -43,4 +43,4 @@ A JavaScript Base62 encode/decoder | ||
Base62.encode(999); // "g7" | ||
Base62.decode("g7"); // 999 | ||
base62.encode(999); // "g7" | ||
base62.decode("g7"); // 999 | ||
``` | ||
@@ -58,4 +58,4 @@ | ||
Base62.encode(999, charset); // "F3" | ||
Base62.decode("F3", charset); // 999 | ||
base62.encode(999, charset); // "F3" | ||
base62.decode("F3", charset); // 999 | ||
``` | ||
@@ -74,6 +74,6 @@ | ||
```javascript | ||
var Base62 = require("base62"); | ||
var base62 = require("base62"); | ||
Base62.encode(999); // "g7" | ||
Base62.decode("g7"); // 999 | ||
base62.encode(999); // "g7" | ||
base62.decode("g7"); // 999 | ||
``` | ||
@@ -86,9 +86,9 @@ | ||
```javascript | ||
var Base62 = require("base62"); | ||
var base62 = require("base62"); | ||
var charset = "~9876543210ABCDEFGHIJKLMNOPQRSTU$#@%!abcdefghijklmnopqrstuvw-="; | ||
Base62.setCharacterSet(charset); | ||
base62.setCharacterSet(charset); | ||
Base62.encode(999); // "F3" | ||
Base62.decode("F3"); // 999 | ||
base62.encode(999); // "F3" | ||
base62.decode("F3"); // 999 | ||
``` | ||
@@ -102,5 +102,5 @@ | ||
Source code is hosted on [GitHub](http://github.com/andrew/base62.js). | ||
Source code is hosted on [GitHub](http://github.com/base62/base62.js). | ||
Please report issues or feature requests in | ||
[GitHub Issues](http://github.com/andrew/base62.js.issues). | ||
[GitHub Issues](http://github.com/base62/base62.js.issues). | ||
@@ -122,3 +122,4 @@ | ||
(e.g. "1.2.3"). | ||
* Create a tag, using the prefixed version number (e.g. `git tag v1.2.3`). | ||
* Create an annotated tag, using the prefixed version number (e.g. | ||
`git tag -am "1.2.3" v1.2.3`). | ||
* Publish the new version: `git push --tags origin master` and `npm publish`. | ||
@@ -129,2 +130,2 @@ | ||
Copyright (c) 2016 Andrew Nesbitt. See [LICENSE](https://github.com/andrew/base62.js/blob/master/LICENSE) for details. | ||
Copyright (c) 2016 Andrew Nesbitt. See [LICENSE](https://github.com/base62/base62.js/blob/master/LICENSE) for details. |
@@ -40,8 +40,12 @@ /* global describe, it */ | ||
it("should encode numbers", function() { | ||
assertSame(encode(10, charset), "A"); | ||
assertSame(encode(65, charset), "ß"); | ||
assertSame(encode(70, charset), "14"); | ||
}); | ||
it("should decode strings", function() { | ||
assertSame(decode("A", charset), 10); | ||
assertSame(decode("ß", charset), 65); | ||
assertSame(decode("14", charset), 70); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
30256
440
125
0