base64-arraybuffer-es6
Advanced tools
Comparing version 0.5.0 to 0.6.0
# base64-arraybuffer-es6 | ||
## 0.6.0 | ||
- Breaking change: Bump to at least Node 0.10.0 (had been using features not supported) | ||
- Linting: Check RC file | ||
- Linting: Use ash-nazg and check HTML and MD | ||
- Testing: Add nyc for coverage | ||
- Testing: Add test of non-null length (brings to 100% coverage) | ||
- Testing: Use register-assert | ||
- npm: Avoid deprecated rollup-plugin-babel in favor of rollup/plugin-babel | ||
- npm: Update core-js-bundle peerDep. and devDeps | ||
## 0.5.0 | ||
@@ -4,0 +15,0 @@ |
@@ -0,1 +1,3 @@ | ||
/* eslint-disable node/no-unsupported-features/es-syntax */ | ||
/* | ||
@@ -15,10 +17,17 @@ * base64-arraybuffer | ||
} | ||
/** | ||
* @param {ArrayBuffer} arraybuffer | ||
* @param {Integer} byteOffset | ||
* @param {Integer} lngth | ||
* @returns {string} | ||
*/ | ||
var encode = function encode(arraybuffer, byteOffset, length) { | ||
if (length === null || length === undefined) { | ||
length = arraybuffer.byteLength; // Needed for Safari | ||
var encode = function encode(arraybuffer, byteOffset, lngth) { | ||
if (lngth === null || lngth === undefined) { | ||
lngth = arraybuffer.byteLength; // Needed for Safari | ||
} | ||
var bytes = new Uint8Array(arraybuffer, byteOffset || 0, // Default needed for Safari | ||
length); | ||
lngth); | ||
var len = bytes.length; | ||
@@ -35,5 +44,5 @@ var base64 = ''; | ||
if (len % 3 === 2) { | ||
base64 = base64.substring(0, base64.length - 1) + '='; | ||
base64 = base64.slice(0, -1) + '='; | ||
} else if (len % 3 === 1) { | ||
base64 = base64.substring(0, base64.length - 2) + '=='; | ||
base64 = base64.slice(0, -2) + '=='; | ||
} | ||
@@ -43,2 +52,7 @@ | ||
}; | ||
/** | ||
* @param {string} base64 | ||
* @returns {ArrayBuffer} | ||
*/ | ||
var decode = function decode(base64) { | ||
@@ -45,0 +59,0 @@ var len = base64.length; |
@@ -5,4 +5,6 @@ (function (global, factory) { | ||
(global = global || self, factory(global.Base64ArrayBuffer = {})); | ||
}(this, function (exports) { 'use strict'; | ||
}(this, (function (exports) { 'use strict'; | ||
/* eslint-disable node/no-unsupported-features/es-syntax */ | ||
/* | ||
@@ -22,10 +24,17 @@ * base64-arraybuffer | ||
} | ||
/** | ||
* @param {ArrayBuffer} arraybuffer | ||
* @param {Integer} byteOffset | ||
* @param {Integer} lngth | ||
* @returns {string} | ||
*/ | ||
var encode = function encode(arraybuffer, byteOffset, length) { | ||
if (length === null || length === undefined) { | ||
length = arraybuffer.byteLength; // Needed for Safari | ||
var encode = function encode(arraybuffer, byteOffset, lngth) { | ||
if (lngth === null || lngth === undefined) { | ||
lngth = arraybuffer.byteLength; // Needed for Safari | ||
} | ||
var bytes = new Uint8Array(arraybuffer, byteOffset || 0, // Default needed for Safari | ||
length); | ||
lngth); | ||
var len = bytes.length; | ||
@@ -42,5 +51,5 @@ var base64 = ''; | ||
if (len % 3 === 2) { | ||
base64 = base64.substring(0, base64.length - 1) + '='; | ||
base64 = base64.slice(0, -1) + '='; | ||
} else if (len % 3 === 1) { | ||
base64 = base64.substring(0, base64.length - 2) + '=='; | ||
base64 = base64.slice(0, -2) + '=='; | ||
} | ||
@@ -50,2 +59,7 @@ | ||
}; | ||
/** | ||
* @param {string} base64 | ||
* @returns {ArrayBuffer} | ||
*/ | ||
var decode = function decode(base64) { | ||
@@ -86,2 +100,2 @@ var len = base64.length; | ||
})); | ||
}))); |
{ | ||
"name": "base64-arraybuffer-es6", | ||
"version": "0.6.0", | ||
"description": "Encode/decode base64 data into ArrayBuffers", | ||
"version": "0.5.0", | ||
"homepage": "https://github.com/brettz9/base64-arraybuffer", | ||
@@ -25,10 +25,10 @@ "author": "Brett Zamir", | ||
"engines": { | ||
"node": ">= 0.6.0" | ||
"node": ">=0.10.0" | ||
}, | ||
"scripts": { | ||
"start": "static -p 8093", | ||
"eslint": "eslint .", | ||
"eslint": "eslint --ext js,md,html .", | ||
"build": "rollup -c", | ||
"mocha": "mocha --require esm test/node-env.js test/*.js", | ||
"test": "npm run eslint && npm run build && npm run mocha", | ||
"mocha": "mocha --require esm --require chai/register-assert test/*.js", | ||
"test": "npm run eslint && npm run build && nyc npm run mocha", | ||
"browser-test": "npm run eslint && npm run build && open-cli http://127.0.0.1:8093/test/ && npm start" | ||
@@ -40,22 +40,36 @@ }, | ||
"peerDependencies": { | ||
"core-js-bundle": "^3.1.3" | ||
"core-js-bundle": "^3.6.5" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@babel/core": "^7.4.5", | ||
"@babel/preset-env": "^7.4.5", | ||
"@babel/core": "^7.9.6", | ||
"@babel/preset-env": "^7.9.6", | ||
"@mysticatea/eslint-plugin": "^13.0.0", | ||
"@rollup/plugin-babel": "^5.0.0", | ||
"chai": "^4.2.0", | ||
"core-js-bundle": "^3.1.3", | ||
"eslint": "5.16.0", | ||
"eslint-config-standard": "12.0.0", | ||
"eslint-plugin-import": "2.17.3", | ||
"eslint-plugin-node": "9.1.0", | ||
"eslint-plugin-promise": "4.1.1", | ||
"eslint-plugin-standard": "4.0.0", | ||
"core-js-bundle": "^3.6.5", | ||
"eslint": "^7.0.0", | ||
"eslint-config-ash-nazg": "^22.0.0", | ||
"eslint-config-standard": "^14.1.1", | ||
"eslint-plugin-array-func": "^3.1.5", | ||
"eslint-plugin-compat": "^3.5.1", | ||
"eslint-plugin-eslint-comments": "^3.1.2", | ||
"eslint-plugin-html": "^6.0.2", | ||
"eslint-plugin-import": "^2.20.2", | ||
"eslint-plugin-jsdoc": "^25.0.1", | ||
"eslint-plugin-markdown": "^1.0.2", | ||
"eslint-plugin-no-unsanitized": "^3.1.1", | ||
"eslint-plugin-no-use-extend-native": "^0.5.0", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-promise": "^4.2.1", | ||
"eslint-plugin-sonarjs": "^0.5.0", | ||
"eslint-plugin-standard": "^4.0.1", | ||
"eslint-plugin-unicorn": "^19.0.1", | ||
"esm": "^3.2.25", | ||
"mocha": "^6.1.4", | ||
"mocha": "^7.1.2", | ||
"node-static": "0.7.11", | ||
"open-cli": "^5.0.0", | ||
"rollup": "1.13.1", | ||
"rollup-plugin-babel": "^4.3.2" | ||
"nyc": "^15.0.1", | ||
"open-cli": "^6.0.1", | ||
"rollup": "2.8.2", | ||
"typescript": "^3.8.3" | ||
}, | ||
@@ -62,0 +76,0 @@ "keywords": [ |
@@ -0,1 +1,2 @@ | ||
/* eslint-disable node/no-unsupported-features/es-syntax */ | ||
/* | ||
@@ -9,3 +10,4 @@ * base64-arraybuffer | ||
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; | ||
const chars = | ||
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; | ||
@@ -18,5 +20,11 @@ // Use a lookup table to find the index. | ||
export const encode = function (arraybuffer, byteOffset, length) { | ||
if (length === null || length === undefined) { | ||
length = arraybuffer.byteLength; // Needed for Safari | ||
/** | ||
* @param {ArrayBuffer} arraybuffer | ||
* @param {Integer} byteOffset | ||
* @param {Integer} lngth | ||
* @returns {string} | ||
*/ | ||
export const encode = function (arraybuffer, byteOffset, lngth) { | ||
if (lngth === null || lngth === undefined) { | ||
lngth = arraybuffer.byteLength; // Needed for Safari | ||
} | ||
@@ -26,3 +34,3 @@ const bytes = new Uint8Array( | ||
byteOffset || 0, // Default needed for Safari | ||
length | ||
lngth | ||
); | ||
@@ -40,5 +48,5 @@ const len = bytes.length; | ||
if ((len % 3) === 2) { | ||
base64 = base64.substring(0, base64.length - 1) + '='; | ||
base64 = base64.slice(0, -1) + '='; | ||
} else if (len % 3 === 1) { | ||
base64 = base64.substring(0, base64.length - 2) + '=='; | ||
base64 = base64.slice(0, -2) + '=='; | ||
} | ||
@@ -49,2 +57,6 @@ | ||
/** | ||
* @param {string} base64 | ||
* @returns {ArrayBuffer} | ||
*/ | ||
export const decode = function (base64) { | ||
@@ -51,0 +63,0 @@ const len = base64.length; |
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
13583
219
30