[Pkg-javascript-commits] [node-vlq] 01/03: New upstream version 0.2.2
Julien Puydt
julien.puydt at laposte.net
Thu Apr 20 16:44:13 UTC 2017
This is an automated email from the git hooks/post-receive script.
jpuydt-guest pushed a commit to annotated tag debian/0.2.2-1
in repository node-vlq.
commit 76b39ba45c8377ea1a62d8ef4e070bfbd8cb9e65
Author: Julien Puydt <julien.puydt at laposte.net>
Date: Thu Apr 20 18:09:12 2017 +0200
New upstream version 0.2.2
---
.eslintrc.json | 39 +++++++++++++++++
CHANGELOG.md | 10 ++++-
bower.json | 15 -------
dist/vlq.js | 131 +++++++++++++++++++++++++++------------------------------
package.json | 17 ++++----
src/vlq.js | 37 +++++++---------
6 files changed, 135 insertions(+), 114 deletions(-)
diff --git a/.eslintrc.json b/.eslintrc.json
new file mode 100644
index 0000000..56fb979
--- /dev/null
+++ b/.eslintrc.json
@@ -0,0 +1,39 @@
+{
+ "root": true,
+ "rules": {
+ "indent": [ 2, "tab", { "SwitchCase": 1 } ],
+ "semi": [ 2, "always" ],
+ "keyword-spacing": [ 2, { "before": true, "after": true } ],
+ "space-before-blocks": [ 2, "always" ],
+ "space-before-function-paren": [ 2, "always" ],
+ "no-mixed-spaces-and-tabs": [ 2, "smart-tabs" ],
+ "no-cond-assign": 0,
+ "no-unused-vars": 2,
+ "object-shorthand": [ 2, "always" ],
+ "no-const-assign": 2,
+ "no-class-assign": 2,
+ "no-this-before-super": 2,
+ "no-var": 0,
+ "no-unreachable": 2,
+ "valid-typeof": 2,
+ "quote-props": [ 2, "as-needed" ],
+ "one-var": [ 2, "never" ],
+ "prefer-arrow-callback": 0,
+ "prefer-const": [ 0, { "destructuring": "all" } ],
+ "arrow-spacing": 2,
+ "no-inner-declarations": 0
+ },
+ "env": {
+ "es6": true,
+ "browser": true,
+ "node": true,
+ "mocha": true
+ },
+ "extends": [
+ "eslint:recommended"
+ ],
+ "parserOptions": {
+ "ecmaVersion": 6,
+ "sourceType": "module"
+ }
+}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 211e53b..8a7729b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,9 +1,17 @@
# changelog
+## 0.2.2
+
+* Expose `pkg.module`, not `jsnext:main`
+
+## 0.2.1
+
+* Performance boost - vlq no longer checks that you've passed a number or an array into `vlq.encode()`, making it significantly faster
+
## 0.2.0
* Author as ES6 module, accessible to ES6-aware systems via the `jsnext:main` field in `package.json`
## 0.1.0
-* First release
\ No newline at end of file
+* First release
diff --git a/bower.json b/bower.json
deleted file mode 100644
index 89ea154..0000000
--- a/bower.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "name": "vlq",
- "description": "Generate, and decode, base64 VLQ mappings for source maps and other uses",
- "author": "Rich Harris",
- "repository": "https://github.com/Rich-Harris/vlq",
- "version": "0.2.0",
- "main": "dist/vlq.js",
- "ignore": [
- ".*",
- "*.json",
- "test",
- "sourcemaps",
- "README.md"
- ]
-}
diff --git a/dist/vlq.js b/dist/vlq.js
index 60748d9..d49ae72 100644
--- a/dist/vlq.js
+++ b/dist/vlq.js
@@ -1,96 +1,91 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
- factory((global.vlq = {}))
-}(this, function (exports) { 'use strict';
+ (factory((global.vlq = global.vlq || {})));
+}(this, (function (exports) { 'use strict';
- exports.decode = decode;
- exports.encode = encode;
+var charToInteger = {};
+var integerToChar = {};
- var charToInteger = {};
- var integerToChar = {};
+'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='.split( '' ).forEach( function ( char, i ) {
+ charToInteger[ char ] = i;
+ integerToChar[ i ] = char;
+});
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='.split( '' ).forEach( function ( char, i ) {
- charToInteger[ char ] = i;
- integerToChar[ i ] = char;
- });
+function decode ( string ) {
+ var result = [];
+ var shift = 0;
+ var value = 0;
- function decode ( string ) {
- var result = [],
- len = string.length,
- i,
- hasContinuationBit,
- shift = 0,
- value = 0,
- integer,
- shouldNegate;
+ for ( var i = 0; i < string.length; i += 1 ) {
+ var integer = charToInteger[ string[i] ];
- for ( i = 0; i < len; i += 1 ) {
- integer = charToInteger[ string[i] ];
-
- if ( integer === undefined ) {
- throw new Error( 'Invalid character (' + string[i] + ')' );
- }
+ if ( integer === undefined ) {
+ throw new Error( 'Invalid character (' + string[i] + ')' );
+ }
- hasContinuationBit = integer & 32;
+ var hasContinuationBit = integer & 32;
- integer &= 31;
- value += integer << shift;
+ integer &= 31;
+ value += integer << shift;
- if ( hasContinuationBit ) {
- shift += 5;
- } else {
- shouldNegate = value & 1;
- value >>= 1;
+ if ( hasContinuationBit ) {
+ shift += 5;
+ } else {
+ var shouldNegate = value & 1;
+ value >>= 1;
- result.push( shouldNegate ? -value : value );
+ result.push( shouldNegate ? -value : value );
- // reset
- value = shift = 0;
- }
+ // reset
+ value = shift = 0;
}
-
- return result;
}
- function encode ( value ) {
- var result;
+ return result;
+}
- if ( typeof value === 'number' ) {
- result = encodeInteger( value );
- } else if ( Array.isArray( value ) ) {
- result = '';
- value.forEach( function ( num ) {
- result += encodeInteger( num );
- });
- } else {
- throw new Error( 'vlq.encode accepts an integer or an array of integers' );
+function encode ( value ) {
+ var result;
+
+ if ( typeof value === 'number' ) {
+ result = encodeInteger( value );
+ } else {
+ result = '';
+ for ( var i = 0; i < value.length; i += 1 ) {
+ result += encodeInteger( value[i] );
}
+ }
+
+ return result;
+}
+
+function encodeInteger ( num ) {
+ var result = '';
- return result;
+ if ( num < 0 ) {
+ num = ( -num << 1 ) | 1;
+ } else {
+ num <<= 1;
}
- function encodeInteger ( num ) {
- var result = '', clamped;
+ do {
+ var clamped = num & 31;
+ num >>= 5;
- if ( num < 0 ) {
- num = ( -num << 1 ) | 1;
- } else {
- num <<= 1;
+ if ( num > 0 ) {
+ clamped |= 32;
}
- do {
- clamped = num & 31;
- num >>= 5;
+ result += integerToChar[ clamped ];
+ } while ( num > 0 );
- if ( num > 0 ) {
- clamped |= 32;
- }
+ return result;
+}
- result += integerToChar[ clamped ];
- } while ( num > 0 );
+exports.decode = decode;
+exports.encode = encode;
- return result;
- }
+Object.defineProperty(exports, '__esModule', { value: true });
-}));
\ No newline at end of file
+})));
diff --git a/package.json b/package.json
index 1a6a5d4..3cda3b2 100644
--- a/package.json
+++ b/package.json
@@ -4,22 +4,23 @@
"author": "Rich Harris",
"repository": "https://github.com/Rich-Harris/vlq",
"license": "MIT",
- "version": "0.2.0",
+ "version": "0.2.2",
"main": "dist/vlq.js",
- "jsnext:main": "src/vlq.js",
+ "module": "src/vlq.js",
"files": [
"README.md",
"src/vlq.js",
"dist/vlq.js"
],
"devDependencies": {
- "esperanto": "^0.6.8",
- "jshint": "^2.6.0"
+ "eslint": "^3.19.0",
+ "rollup": "^0.41.6"
},
"scripts": {
- "build": "esperanto -i src/vlq.js -o dist/vlq.js -t umd -n vlq -s",
- "lint": "jshint src",
- "test": "node test",
- "prepublish": "npm run lint; npm run build; npm test"
+ "build": "rollup src/vlq.js -n vlq -f umd > dist/vlq.js",
+ "lint": "eslint src",
+ "test": "node test",
+ "pretest": "npm run build",
+ "prepublish": "npm test"
}
}
diff --git a/src/vlq.js b/src/vlq.js
index e99ce87..bdf2bcd 100644
--- a/src/vlq.js
+++ b/src/vlq.js
@@ -7,23 +7,18 @@ var integerToChar = {};
});
export function decode ( string ) {
- var result = [],
- len = string.length,
- i,
- hasContinuationBit,
- shift = 0,
- value = 0,
- integer,
- shouldNegate;
-
- for ( i = 0; i < len; i += 1 ) {
- integer = charToInteger[ string[i] ];
+ var result = [];
+ var shift = 0;
+ var value = 0;
+
+ for ( var i = 0; i < string.length; i += 1 ) {
+ var integer = charToInteger[ string[i] ];
if ( integer === undefined ) {
throw new Error( 'Invalid character (' + string[i] + ')' );
}
- hasContinuationBit = integer & 32;
+ var hasContinuationBit = integer & 32;
integer &= 31;
value += integer << shift;
@@ -31,7 +26,7 @@ export function decode ( string ) {
if ( hasContinuationBit ) {
shift += 5;
} else {
- shouldNegate = value & 1;
+ var shouldNegate = value & 1;
value >>= 1;
result.push( shouldNegate ? -value : value );
@@ -49,20 +44,18 @@ export function encode ( value ) {
if ( typeof value === 'number' ) {
result = encodeInteger( value );
- } else if ( Array.isArray( value ) ) {
- result = '';
- value.forEach( function ( num ) {
- result += encodeInteger( num );
- });
} else {
- throw new Error( 'vlq.encode accepts an integer or an array of integers' );
+ result = '';
+ for ( var i = 0; i < value.length; i += 1 ) {
+ result += encodeInteger( value[i] );
+ }
}
return result;
}
function encodeInteger ( num ) {
- var result = '', clamped;
+ var result = '';
if ( num < 0 ) {
num = ( -num << 1 ) | 1;
@@ -71,7 +64,7 @@ function encodeInteger ( num ) {
}
do {
- clamped = num & 31;
+ var clamped = num & 31;
num >>= 5;
if ( num > 0 ) {
@@ -82,4 +75,4 @@ function encodeInteger ( num ) {
} while ( num > 0 );
return result;
-}
\ No newline at end of file
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-vlq.git
More information about the Pkg-javascript-commits
mailing list