[Pkg-javascript-commits] [node-vlq] 02/04: New upstream version 1.0.0

Julien Puydt julien.puydt at laposte.net
Mon Jan 15 10:22:37 UTC 2018


This is an automated email from the git hooks/post-receive script.

jpuydt-guest pushed a commit to branch master
in repository node-vlq.

commit a6aa5ade4ceb72dd2ab1ea8edb3e2f03c3aaba4f
Author: Julien Puydt <julien.puydt at laposte.net>
Date:   Mon Jan 15 10:57:48 2018 +0100

    New upstream version 1.0.0
---
 .gitignore             |  3 +-
 CHANGELOG.md           |  4 +++
 dist/vlq.js            | 91 --------------------------------------------------
 package-lock.json      | 77 +++++++++++++++++++++++++++++++-----------
 package.json           | 15 +++++----
 rollup.config.js       | 21 ++++++++++++
 src/{vlq.js => vlq.ts} | 32 +++++++++---------
 tsconfig.json          | 18 ++++++++++
 8 files changed, 127 insertions(+), 134 deletions(-)

diff --git a/.gitignore b/.gitignore
index 0a33161..b5061e6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
 .DS_Store
 tmp*
-node_modules
\ No newline at end of file
+node_modules
+dist
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 08a3320..c32339e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
 # changelog
 
+## 1.0.0
+
+* Rewrite in TypeScript, include definitions in package ([#6](https://github.com/Rich-Harris/vlq/pull/6))
+
 ## 0.2.3
 
 * Add LICENSE to npm package
diff --git a/dist/vlq.js b/dist/vlq.js
deleted file mode 100644
index d49ae72..0000000
--- a/dist/vlq.js
+++ /dev/null
@@ -1,91 +0,0 @@
-(function (global, factory) {
-	typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
-	typeof define === 'function' && define.amd ? define(['exports'], factory) :
-	(factory((global.vlq = global.vlq || {})));
-}(this, (function (exports) { 'use strict';
-
-var charToInteger = {};
-var integerToChar = {};
-
-'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='.split( '' ).forEach( function ( char, i ) {
-	charToInteger[ char ] = i;
-	integerToChar[ i ] = char;
-});
-
-function decode ( string ) {
-	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] + ')' );
-		}
-
-		var hasContinuationBit = integer & 32;
-
-		integer &= 31;
-		value += integer << shift;
-
-		if ( hasContinuationBit ) {
-			shift += 5;
-		} else {
-			var shouldNegate = value & 1;
-			value >>= 1;
-
-			result.push( shouldNegate ? -value : value );
-
-			// reset
-			value = shift = 0;
-		}
-	}
-
-	return result;
-}
-
-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 = '';
-
-	if ( num < 0 ) {
-		num = ( -num << 1 ) | 1;
-	} else {
-		num <<= 1;
-	}
-
-	do {
-		var clamped = num & 31;
-		num >>= 5;
-
-		if ( num > 0 ) {
-			clamped |= 32;
-		}
-
-		result += integerToChar[ clamped ];
-	} while ( num > 0 );
-
-	return result;
-}
-
-exports.decode = decode;
-exports.encode = encode;
-
-Object.defineProperty(exports, '__esModule', { value: true });
-
-})));
diff --git a/package-lock.json b/package-lock.json
index e301e3b..3b5a4cc 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
 {
   "name": "vlq",
-  "version": "0.2.3",
+  "version": "1.0.0",
   "lockfileVersion": 1,
   "requires": true,
   "dependencies": {
@@ -179,6 +179,12 @@
       "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=",
       "dev": true
     },
+    "compare-versions": {
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-2.0.1.tgz",
+      "integrity": "sha1-Htwfk2h/2XoyXFn1XkWgfbEGrKY=",
+      "dev": true
+    },
     "concat-map": {
       "version": "0.0.1",
       "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
@@ -423,6 +429,12 @@
       "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=",
       "dev": true
     },
+    "estree-walker": {
+      "version": "0.2.1",
+      "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.2.1.tgz",
+      "integrity": "sha1-va/oCVOD2EFNXcLs9MkXO225QS4=",
+      "dev": true
+    },
     "esutils": {
       "version": "2.0.2",
       "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz",
@@ -959,12 +971,40 @@
       }
     },
     "rollup": {
-      "version": "0.41.6",
-      "resolved": "https://registry.npmjs.org/rollup/-/rollup-0.41.6.tgz",
-      "integrity": "sha1-4NBUl4d6OYwQTYFtJzOnGKepTio=",
+      "version": "0.53.3",
+      "resolved": "https://registry.npmjs.org/rollup/-/rollup-0.53.3.tgz",
+      "integrity": "sha512-MADFV0jpoh1QDB6U0U6YamGihGetxHEYgwTcGsc7map6JFIydPEfGNshK+ozxv1RKeUOQKn1vRb85IAcdjL22Q==",
+      "dev": true
+    },
+    "rollup-plugin-typescript": {
+      "version": "0.8.1",
+      "resolved": "https://registry.npmjs.org/rollup-plugin-typescript/-/rollup-plugin-typescript-0.8.1.tgz",
+      "integrity": "sha1-L/fuzCHPa7K0P8J+W2iJUs5xkko=",
+      "dev": true,
+      "requires": {
+        "compare-versions": "2.0.1",
+        "object-assign": "4.1.1",
+        "rollup-pluginutils": "1.5.2",
+        "tippex": "2.3.1",
+        "typescript": "1.8.10"
+      },
+      "dependencies": {
+        "typescript": {
+          "version": "1.8.10",
+          "resolved": "https://registry.npmjs.org/typescript/-/typescript-1.8.10.tgz",
+          "integrity": "sha1-tHXW4N/wv1DyluXKbvn7tccyDx4=",
+          "dev": true
+        }
+      }
+    },
+    "rollup-pluginutils": {
+      "version": "1.5.2",
+      "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-1.5.2.tgz",
+      "integrity": "sha1-HhVud4+UtyVb+hs9AXi+j1xVJAg=",
       "dev": true,
       "requires": {
-        "source-map-support": "0.4.18"
+        "estree-walker": "0.2.1",
+        "minimatch": "3.0.4"
       }
     },
     "run-async": {
@@ -1005,21 +1045,6 @@
       "integrity": "sha1-7b+JA/ZvfOL46v1s7tZeJkyDGzU=",
       "dev": true
     },
-    "source-map": {
-      "version": "0.5.7",
-      "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
-      "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=",
-      "dev": true
-    },
-    "source-map-support": {
-      "version": "0.4.18",
-      "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.18.tgz",
-      "integrity": "sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA==",
-      "dev": true,
-      "requires": {
-        "source-map": "0.5.7"
-      }
-    },
     "sprintf-js": {
       "version": "1.0.3",
       "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
@@ -1132,6 +1157,12 @@
       "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=",
       "dev": true
     },
+    "tippex": {
+      "version": "2.3.1",
+      "resolved": "https://registry.npmjs.org/tippex/-/tippex-2.3.1.tgz",
+      "integrity": "sha1-ov1bcIfXy/sgyYBqbBYQjCwPr9o=",
+      "dev": true
+    },
     "tryit": {
       "version": "1.0.3",
       "resolved": "https://registry.npmjs.org/tryit/-/tryit-1.0.3.tgz",
@@ -1153,6 +1184,12 @@
       "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=",
       "dev": true
     },
+    "typescript": {
+      "version": "2.6.2",
+      "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.6.2.tgz",
+      "integrity": "sha1-PFtv1/beCRQmkCfwPAlGdY92c6Q=",
+      "dev": true
+    },
     "user-home": {
       "version": "2.0.0",
       "resolved": "https://registry.npmjs.org/user-home/-/user-home-2.0.0.tgz",
diff --git a/package.json b/package.json
index 5cff8f8..ea08e68 100644
--- a/package.json
+++ b/package.json
@@ -4,21 +4,24 @@
   "author": "Rich Harris",
   "repository": "https://github.com/Rich-Harris/vlq",
   "license": "MIT",
-  "version": "0.2.3",
+  "version": "1.0.0",
   "main": "dist/vlq.js",
-  "module": "src/vlq.js",
+  "module": "dist/vlq.es.js",
+  "types": "dist/types/vlq.d.ts",
   "files": [
     "README.md",
     "LICENSE",
-    "src/vlq.js",
-    "dist/vlq.js"
+    "dist/*.js",
+    "dist/**/*.d.ts"
   ],
   "devDependencies": {
     "eslint": "^3.19.0",
-    "rollup": "^0.41.6"
+    "rollup": "^0.53.3",
+    "rollup-plugin-typescript": "^0.8.1",
+    "typescript": "^2.6.2"
   },
   "scripts": {
-    "build": "rollup src/vlq.js -n vlq -f umd > dist/vlq.js",
+    "build": "rollup -c && tsc",
     "lint": "eslint src",
     "test": "node test",
     "pretest": "npm run build",
diff --git a/rollup.config.js b/rollup.config.js
new file mode 100644
index 0000000..5dd7dea
--- /dev/null
+++ b/rollup.config.js
@@ -0,0 +1,21 @@
+import typescript from 'rollup-plugin-typescript';
+
+const pkg = require('./package.json');
+
+export default {
+	input: 'src/vlq.ts',
+	output: [{
+		file: pkg.main,
+		format: 'umd',
+		name: 'vlq'
+	}, {
+		file: pkg.module,
+		format: 'es'
+	}],
+	plugins: [
+		typescript({
+			exclude: 'node_modules/**',
+			typescript: require('typescript')
+		})
+	]
+};
diff --git a/src/vlq.js b/src/vlq.ts
similarity index 59%
rename from src/vlq.js
rename to src/vlq.ts
index bdf2bcd..042cf79 100644
--- a/src/vlq.js
+++ b/src/vlq.ts
@@ -1,24 +1,24 @@
-var charToInteger = {};
-var integerToChar = {};
+let charToInteger: { [char: string]: number } = {};
+let integerToChar: { [integer: number]: string } = {};
 
 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='.split( '' ).forEach( function ( char, i ) {
 	charToInteger[ char ] = i;
 	integerToChar[ i ] = char;
 });
 
-export function decode ( string ) {
-	var result = [];
-	var shift = 0;
-	var value = 0;
+export function decode ( string: string ): number[] {
+	let result: number[] = [];
+	let shift = 0;
+	let value = 0;
 
-	for ( var i = 0; i < string.length; i += 1 ) {
-		var integer = charToInteger[ string[i] ];
+	for ( let i = 0; i < string.length; i += 1 ) {
+		let integer = charToInteger[ string[i] ];
 
 		if ( integer === undefined ) {
 			throw new Error( 'Invalid character (' + string[i] + ')' );
 		}
 
-		var hasContinuationBit = integer & 32;
+		const hasContinuationBit = integer & 32;
 
 		integer &= 31;
 		value += integer << shift;
@@ -26,7 +26,7 @@ export function decode ( string ) {
 		if ( hasContinuationBit ) {
 			shift += 5;
 		} else {
-			var shouldNegate = value & 1;
+			const shouldNegate = value & 1;
 			value >>= 1;
 
 			result.push( shouldNegate ? -value : value );
@@ -39,14 +39,14 @@ export function decode ( string ) {
 	return result;
 }
 
-export function encode ( value ) {
-	var result;
+export function encode ( value: number | number[] ): string {
+	let result: string;
 
 	if ( typeof value === 'number' ) {
 		result = encodeInteger( value );
 	} else {
 		result = '';
-		for ( var i = 0; i < value.length; i += 1 ) {
+		for ( let i = 0; i < value.length; i += 1 ) {
 			result += encodeInteger( value[i] );
 		}
 	}
@@ -54,8 +54,8 @@ export function encode ( value ) {
 	return result;
 }
 
-function encodeInteger ( num ) {
-	var result = '';
+function encodeInteger ( num: number ): string {
+	let result = '';
 
 	if ( num < 0 ) {
 		num = ( -num << 1 ) | 1;
@@ -64,7 +64,7 @@ function encodeInteger ( num ) {
 	}
 
 	do {
-		var clamped = num & 31;
+		let clamped = num & 31;
 		num >>= 5;
 
 		if ( num > 0 ) {
diff --git a/tsconfig.json b/tsconfig.json
new file mode 100644
index 0000000..563a16f
--- /dev/null
+++ b/tsconfig.json
@@ -0,0 +1,18 @@
+{
+	"compilerOptions": {
+		"noImplicitAny": true,
+		"diagnostics": true,
+		"noImplicitThis": true,
+		"noEmitOnError": true,
+		"target": "es5",
+		"lib": ["es5", "es6"],
+		"declaration": true,
+		"outDir": "dist/types"
+	},
+	"include": [
+		"src"
+	],
+	"exclude": [
+		"node_modules"
+	]
+}

-- 
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