endianness
Advanced tools
Comparing version 8.0.1 to 8.0.2
# CHANGELOG | ||
## version 8.0.1 (2018-08-03) | ||
## version 8.0.2 (2018-08-03) | ||
- compatible with IE6+ | ||
@@ -5,0 +5,0 @@ - iife UMD |
@@ -1,1 +0,77 @@ | ||
;var endianness=(function(exports){function endianness(d,c,a,b){b=void 0===b?d.length:b;if(b%c)throw Error("Bad buffer length.");for(a=void 0===a?0:a;a<b;a+=c)swap(d,c,a)}function swap(d,c,a){c--;for(var b=0;b<c;b++){var e=d[a+b];d[a+b]=d[a+c];d[a+c]=e;c--}};var exports = exports || {}; exports = endianness; exports.endianness = endianness; exports['default'] = endianness;typeof module !== 'undefined' ? module.exports = endianness :typeof define === 'function' && define.amd ? define(['exports'], endianness) :typeof global !== 'undefined' ? global.endianness = endianness : null; return endianness;})(); | ||
(function (global, factory) {typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :typeof define === 'function' && define.amd ? define(factory) :(global.endianness = factory());}(this, (function () { 'use strict' | ||
var endianness = (function () { | ||
'use strict'; | ||
/* | ||
* Copyright (c) 2017-2018 Rafael da Silva Rocha. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining | ||
* a copy of this software and associated documentation files (the | ||
* "Software"), to deal in the Software without restriction, including | ||
* without limitation the rights to use, copy, modify, merge, publish, | ||
* distribute, sublicense, and/or sell copies of the Software, and to | ||
* permit persons to whom the Software is furnished to do so, subject to | ||
* the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be | ||
* included in all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
* | ||
*/ | ||
/** | ||
* @fileoverview A function to swap endianness in byte buffers. | ||
* @see https://github.com/rochars/endianness | ||
*/ | ||
/** @module endianness */ | ||
/** | ||
* Swap the byte ordering in a buffer. The buffer is modified in place. | ||
* @param {!Array|!Uint8Array} bytes The bytes. | ||
* @param {number} offset The byte offset. | ||
* @param {number=} start The start index. Assumes 0. | ||
* @param {number=} end The end index. Assumes the buffer length. | ||
* @throws {Error} If the buffer length is not valid. | ||
*/ | ||
function endianness(bytes, offset) { | ||
var start = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0; | ||
var end = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : bytes.length; | ||
if (end % offset) { | ||
throw new Error("Bad buffer length."); | ||
} | ||
for (var index = start; index < end; index += offset) { | ||
swap(bytes, offset, index); | ||
} | ||
} | ||
/** | ||
* Swap the byte order of a value in a buffer. The buffer is modified in place. | ||
* @param {!Array|!Uint8Array} bytes The bytes. | ||
* @param {number} offset The byte offset. | ||
* @param {number} index The start index. | ||
* @private | ||
*/ | ||
function swap(bytes, offset, index) { | ||
offset--; | ||
for (var x = 0; x < offset; x++) { | ||
/** @type {*} */ | ||
var theByte = bytes[index + x]; | ||
bytes[index + x] = bytes[index + offset]; | ||
bytes[index + offset] = theByte; | ||
offset--; | ||
} | ||
} | ||
return endianness; | ||
}()); | ||
var module = module || {}; module.exports = endianness; module.exports['default'] = endianness; return endianness;}))); |
{ | ||
"name": "endianness", | ||
"version": "8.0.1", | ||
"version": "8.0.2", | ||
"description": "Swap endianness in byte arrays.", | ||
@@ -50,8 +50,10 @@ "homepage": "https://github.com/rochars/endianness", | ||
"devDependencies": { | ||
"codecov": "^3.0.2", | ||
"babel-core": "^6.26.3", | ||
"babel-plugin-external-helpers": "^6.22.0", | ||
"babel-preset-es2015": "^6.24.1", | ||
"codecov": "^3.0.4", | ||
"docdash": "^0.4.0", | ||
"esm": "^3.0.51", | ||
"google-closure-compiler": "^20180610.0.2", | ||
"esm": "^3.0.74", | ||
"jsdoc": "^3.5.5", | ||
"jshint": "^2.9.5", | ||
"jshint": "^2.9.6", | ||
"mocha": "^5.2.0", | ||
@@ -61,4 +63,3 @@ "mocha-lcov-reporter": "^1.3.0", | ||
"rollup": "^0.61.2", | ||
"rollup-plugin-bundleutils": "^1.0.6", | ||
"rollup-plugin-closure-compiler-js": "^1.0.6", | ||
"rollup-plugin-babel": "^3.0.7", | ||
"typescript": "^2.9.2" | ||
@@ -65,0 +66,0 @@ }, |
@@ -15,4 +15,4 @@ # endianness | ||
- **Use it with any byte offset** | ||
- **Swap entire buffers** | ||
- **Swap only a slice of the buffer** | ||
- **Less than 1kb minified!** | ||
@@ -19,0 +19,0 @@ ## Install |
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
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
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
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
14696
147
14