endianness
Advanced tools
Comparing version 1.0.0 to 1.0.1
/* | ||
endianness: Swap byte endianness in a array of bytes. | ||
endianness: Swap byte endianness in arrays. | ||
Copyright (c) 2017 Rafael da Silva Rocha. | ||
https://github.com/rochars/endianness | ||
*/ | ||
(function(d){function b(a){if(e[a])return e[a].a;var c=e[a]={m:a,f:!1,a:{}};d[a].call(c.a,c,c.a,b);c.f=!0;return c.a}var e={};b.l=d;b.h=e;b.b=function(a,c){b.c(a)||Object.defineProperty(a,"a",{configurable:!1,enumerable:!0,get:c})};b.i=function(a){var c=a&&a.g?function(){return a["default"]}:function(){return a};b.b(c,c);return c};b.c=function(a){return Object.prototype.hasOwnProperty.call(a,"a")};b.j="";return b(b.o=0)})([function(){window.endianness=function(d,b){for(var e=d.length,a=0;a<e;){for(var c, | ||
f=d,g=a,h=0,k=b-1,l=parseInt(b/2,10);h<l;)c=f[g+h],f[g+h]=f[g+k],f[g+k]=c,h++,k--;a+=b}return d}}]); |
@@ -71,11 +71,12 @@ /******/ (function(modules) { // webpackBootstrap | ||
/*! | ||
* endianness: Swap byte endianness in a array of bytes. | ||
* endianness: Swap byte endianness in arrays. | ||
* Copyright (c) 2017 Rafael da Silva Rocha. | ||
* https://github.com/rochars/endianness | ||
* | ||
*/ | ||
/** | ||
* Make the resulting byte array big endian or little endian. | ||
* Swap the endianness of units of information in a array of bytes. | ||
* @param {!Array<number>|Uint8Array} bytes An array of bytes. | ||
* @param {number} offset The swap offset according to the bit depth. | ||
* @param {number} offset The offset according to the bit depth. | ||
* - 2 for 16-bit | ||
@@ -99,3 +100,3 @@ * - 3 for 24-bit | ||
/** | ||
* Swap the endianees of a unit of information in a array of bytes. | ||
* Swap the endianness of a unit of information in a array of bytes. | ||
* @param {!Array<number>|Uint8Array} bytes An array of bytes. | ||
@@ -102,0 +103,0 @@ * @param {number} i The index to read. |
/*! | ||
* endianness: Swap byte endianness in a array of bytes. | ||
* endianness: Swap byte endianness in arrays. | ||
* Copyright (c) 2017 Rafael da Silva Rocha. | ||
* https://github.com/rochars/endianness | ||
* | ||
*/ | ||
/** | ||
* Make the resulting byte array big endian or little endian. | ||
* Swap the endianness of units of information in a array of bytes. | ||
* @param {!Array<number>|Uint8Array} bytes An array of bytes. | ||
* @param {number} offset The swap offset according to the bit depth. | ||
* @param {number} offset The offset according to the bit depth. | ||
* - 2 for 16-bit | ||
@@ -29,3 +30,3 @@ * - 3 for 24-bit | ||
/** | ||
* Swap the endianees of a unit of information in a array of bytes. | ||
* Swap the endianness of a unit of information in a array of bytes. | ||
* @param {!Array<number>|Uint8Array} bytes An array of bytes. | ||
@@ -32,0 +33,0 @@ * @param {number} i The index to read. |
{ | ||
"name": "endianness", | ||
"version": "1.0.0", | ||
"description": "Swap byte endianness in byte arrays.", | ||
"version": "1.0.1", | ||
"description": "Swap byte endianness in arrays.", | ||
"homepage": "https://github.com/rochars/endianness", | ||
@@ -12,4 +12,5 @@ "author": "Rafael da Silva Rocha <rocha.rafaelsilva@gmail.com>", | ||
"Uint8Array", | ||
"big endian", | ||
"little endian", | ||
"big-endian", | ||
"little-endian", | ||
"endian", | ||
"endianness", | ||
@@ -16,0 +17,0 @@ "swap" |
# endianness | ||
Swap byte endianness in a array of bytes. | ||
Copyright (c) 2017 Rafael da Silva Rocha. | ||
Swap byte endianness in arrays. | ||
Copyright (c) 2017 Rafael da Silva Rocha. MIT License. | ||
https://github.com/rochars/endianness | ||
@@ -19,11 +19,32 @@ | ||
## Use | ||
Swaping a 64-bit number (8 bytes): | ||
## Example | ||
```javascript | ||
const endianness = require("endianness"); | ||
// Swap endianness of one 64-bit value: | ||
endianness.endianness([64, 9, 33, 251, 84, 68, 45, 24], 8); | ||
//[24, 45, 68, 84, 251, 33, 9, 64] | ||
// Swap endianness of two 24-bit values: | ||
endianness.endianness( | ||
["00", "00", "80", "ff", "ff", "7f"], 3), | ||
// ["80", "00", "00", "7f", "ff", "ff"]); | ||
``` | ||
## Use | ||
```javascript | ||
/** | ||
* Swap the endianness of units of information in a array of bytes. | ||
* @param {!Array<number>|Uint8Array} bytes An array of bytes. | ||
* @param {number} offset The offset according to the bit depth. | ||
* - 2 for 16-bit | ||
* - 3 for 24-bit | ||
* - 4 for 32-bit | ||
* - 5 for 40-bit | ||
* - 6 for 48-bit | ||
* - 8 for 64-bit | ||
*/ | ||
function endianness(bytes, offset) {} | ||
``` | ||
## Browser | ||
@@ -30,0 +51,0 @@ ```html |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
1034698
763
79