8000 ported improvements from forks, updated dependencies · arduino/cbor-js@55fd390 · GitHub
[go: up one dir, main page]

Skip to content

Commit 55fd390

Browse files
author
Stefania
committed
ported improvements from forks, updated dependencies
1 parent 65dc496 commit 55fd390

File tree

9 files changed

+79
-109
lines changed

9 files changed

+79
-109
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
bower_components
1+
temp
22
coverage
33
node_modules
44

55
cbor-js.zip
66
cbor.min.js
77
sauce_connect.log
8+
9+
package-lock.json

Gruntfile.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,6 @@ module.exports = function(grunt) {
5353

5454
grunt.initConfig({
5555
pkg: grunt.file.readJSON("package.json"),
56-
"bower-install-simple": {
57-
all: {
58-
options: {
59-
production: false
60-
}
61-
}
62-
},
6356
compress: {
6457
all: {
6558
options: {
@@ -77,7 +70,7 @@ module.exports = function(grunt) {
7770
connect: {
7871
server: {
7972
options: {
80-
base: "",
73+
base: '',
8174
port: testPort
8275
}
8376
}
@@ -131,10 +124,8 @@ module.exports = function(grunt) {
131124
all: {
132125
options: {
133126
urls: [testBaseURL + testFile, testBaseURL + testFileMin],
134-
build: process.env.TRAVIS_JOB_NUMBER || "unknown",
135127
browsers: browsers,
136128
statusCheckAttempts: -1,
137-
tags: [process.env.TRAVIS_BRANCH || "unknown"],
138129
throttled: 6
139130
}
140131
}
@@ -151,7 +142,6 @@ module.exports = function(grunt) {
151142
}
152143
});
153144

154-
grunt.loadNpmTasks("grunt-bower-install-simple");
155145
grunt.loadNpmTasks("grunt-contrib-compress");
156146
grunt.loadNpmTasks("grunt-contrib-connect");
157147
grunt.loadNpmTasks("grunt-contrib-jshint");
@@ -162,7 +152,7 @@ module.exports = function(grunt) {
162152
grunt.loadNpmTasks("grunt-saucelabs");
163153

164154
grunt.registerTask("default", ["test"]);
165-
grunt.registerTask("test", ["bower-install-simple", "qunit:src", "jshint"]);
166-
grunt.registerTask("test-min", ["bower-install-simple", "uglify", "qunit:min"]);
155+
grunt.registerTask("test", ["qunit:src", "jshint"]);
156+
grunt.registerTask("test-min", ["uglify", "qunit:min"]);
167157
grunt.registerTask("ci", ["test", "coveralls", "test-min", "connect", "saucelabs-qunit", "compress"]);
168158
};

README.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,6 @@ cbor-js
33

44
The Concise Binary Object Representation (CBOR) data format ([RFC 7049](http://tools.ietf.org/html/rfc7049)) implemented in pure JavaScript.
55

6-
[![Build Status](https://api.travis-ci.org/paroga/cbor-js.svg)](https://travis-ci.org/paroga/cbor-js)
7-
[![Coverage Status](https://coveralls.io/repos/paroga/cbor-js/badge.svg?branch=master)](https://coveralls.io/r/paroga/cbor-js?branch=master)
8-
[![Dependency status](https://david-dm.org/paroga/cbor-js/status.svg)](https://david-dm.org/paroga/cbor-js#info=dependencies&view=table)
9-
[![Dev Dependency Status](https://david-dm.org/paroga/cbor-js/dev-status.svg)](https://david-dm.org/paroga/cbor-js#info=devDependencies&view=table)
10-
[![Selenium Test Status](https://saucelabs.com/buildstatus/paroga-cbor-js)](https://saucelabs.com/u/paroga-cbor-js)
11-
12-
[![Selenium Test Status](https://saucelabs.com/browser-matrix/paroga-cbor-js.svg)](https://saucelabs.com/u/paroga-cbor-js)
13-
146
API
157
---
168

bower.json

Lines changed: 0 additions & 25 deletions
This file was deleted.

cbor.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@
2323
*/
2424

2525
(function(global, undefined) { "use strict";
26-
var POW_2_24 = 5.960464477539063e-8,
27-
POW_2_32 = 4294967296,
28-
POW_2_53 = 9007199254740992;
26+
const POW_2_24 = 5.960464477539063e-8;
27+
const POW_2_32 = 4294967296;
28+
const POW_2_53 = 9007199254740992;
29+
const DECODE_CHUNK_SIZE = 8192;
2930

3031
function encode(value) {
3132
var data = new ArrayBuffer(256);
3233
var dataView = new DataView(data);
34+
var byteView = new Uint8Array(data);
3335
var lastLength;
3436
var offset = 0;
3537

@@ -42,6 +44,7 @@ function encode(value) {
4244
var oldDataView = dataView;
4345
data = new ArrayBuffer(newByteLength);
4446
dataView = new DataView(data);
47+
byteView = new Uint8Array(data);
4548
var uint32count = (offset + 3) >> 2;
4649
for (var i = 0; i < uint32count; ++i)
4750
dataView.setUint32(i << 2, oldDataView.getUint32(i << 2));
@@ -60,9 +63,8 @@ function encode(value) {
6063
commitWrite(prepareWrite(1).setUint8(offset, value));
6164
}
6265
function writeUint8Array(value) {
63-
var dataView = prepareWrite(value.length);
64-
for (var i = 0; i < value.length; ++i)
65-
dataView.setUint8(offset + i, value[i]);
66+
prepareWrite(value.length);
67+
byteView.set(value, offset);
6668
commitWrite();
6769
}
6870
function writeUint16(value) {
@@ -350,7 +352,14 @@ function decode(data, tagger, simpleValue) {
350352
appendUtf16Data(utf16data, length);
351353
} else
352354
appendUtf16Data(utf16data, length);
353-
return String.fromCharCode.apply(null, utf16data);
355+
var string = "";
356+
for (i = 0; i < utf16data.length; i += DECODE_CHUNK_SIZE) {
357+
string += String.fromCharCode.apply(
358+
null,
359+
utf16data.slice(i, i + DECODE_CHUNK_SIZE 10000 )
360+
);
361+
}
362+
return string;
354363
case 4:
355364
var retArray;
356365
if (length < 0) {

package.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
"name": "cbor-js",
2+
"name": "@arduino/cbor-js",
33
"version": "0.1.1",
44
"description": "The Concise Binary Object Representation (CBOR) data format (RFC7049) implemented in pure JavaScript.",
55
"keywords": [
66
"cbor"
77
],
8-
"homepage": "https://github.com/paroga/cbor-js",
9-
"bugs": "https://github.com/paroga/cbor-js/issues",
8+
"homepage": "https://github.com/arduino/cbor-js",
9+
"bugs": "https://github.com/arduino/cbor-js/issues",
1010
"license": "MIT",
1111
"author": "Patrick Gansterer <paroga@paroga.com> (http://paroga.com/)",
1212
"main": "cbor.js",
@@ -15,23 +15,23 @@
1515
],
1616
"repository": {
1717
"type": "git",
18-
"url": "http://github.com/paroga/cbor-js.git"
18+
"url": "http://github.com/arduino/cbor-js.git"
1919
},
2020
"scripts": {
2121
"test": "grunt test",
2222
"ci": "grunt ci"
2323
},
2424
"devDependencies": {
25-
"grunt": "~0.4.5",
26-
"grunt-bower-install-simple": "~1.1.4",
27-
"grunt-cli": "~0.1.13",
28-
"grunt-contrib-compress": "~0.13.0",
29-
"grunt-contrib-connect": "~0.11.2",
30-
"grunt-contrib-jshint": "~0.11.2",
31-
"grunt-contrib-qunit": "~0.7.0",
32-
"grunt-contrib-uglify": "~0.9.1",
33-
"grunt-coveralls": "~1.0.0",
34-
"grunt-qunit-istanbul": "~0.4.7",
35-
"grunt-saucelabs": "~8.6.1"
25+
"grunt": "^1.0.3",
26+
"grunt-cli": "^1.3.2",
27+
"grunt-contrib-compress": "^1.4.3",
28+
"grunt-contrib-connect": "^2.0.0",
29+
"grunt-contrib-jshint": "^2.0.0",
30+
"grunt-contrib-qunit": "^3.1.0",
31+
"grunt-contrib-uglify": "^4.0.0",
32+
"grunt-coveralls": "^2.0.0",
33+
"grunt-qunit-istanbul": "^1.0.0",
34+
"grunt-saucelabs": "^9.0.1",
35+
"qunit": "2.9.2"
3636
}
3737
}

test/index.html

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
<head>
44
<meta charset="utf-8">
55
<title>QUnit Tests</title>
6-
<link rel="stylesheet" href="../bower_components/qunit/qunit/qunit.css">
6+
<link rel="stylesheet" href="../node_modules/qunit/qunit/qunit.css">
7+
<script src="../cbor.js"></script>
78
</head>
89
<body>
910
<div id="qunit"></div>
1011
<div id="qunit-fixture"></div>
11-
<script src="../bower_components/qunit/qunit/qunit.js"></script>
12-
<script src="../cbor.js"></script>
13-
<script src="../cbor.js"></script>
12+
<script src="../node_modules/qunit/qunit/qunit.js"></script>
1413
<script>
1514
function define(id, obj) {
1615
if (!arguments.callee.amd)
@@ -20,12 +19,8 @@
2019
if (!("decode" in obj && "encode" in obj))
2120
throw "Unecpected object";
2221
}
23-
</script>
24-
<script src="../cbor.js"></script>
25-
<script>
2622
define.amd = {};
2723
</script>
28-
<script src="../cbor.js"></script>
2924
<script src="./tests.js"></script>
3025
<script>
3126
QUnit.done(function(results){

test/index.min.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
<head>
44
<meta charset="utf-8">
55
<title>QUnit Tests</title>
6-
<link rel="stylesheet" href="../bower_components/qunit/qunit/qunit.css">
6+
<link rel="stylesheet" href="../node_modules/qunit/qunit/qunit.css">
7+
<script src="../cbor.js"></script>
78
</head>
89
<body>
910
<div id="qunit"></div>
1011
<div id="qunit-fixture"></div>
11-
<script src="../bower_components/qunit/qunit/qunit.js"></script>
12-
<script src="../cbor.min.js"></script>
12+
<script src="../node_modules/qunit/qunit/qunit.js"></script>
1313
<script src="./tests.js"></script>
1414
<script>
1515
QUnit.done(function(results){

0 commit comments

Comments
 (0)
0