endianness
Advanced tools
Comparing version 3.0.0 to 3.0.1
@@ -8,3 +8,3 @@ /* | ||
*/ | ||
(function(e){function b(a){if(d[a])return d[a].a;var c=d[a]={m:a,f:!1,a:{}};e[a].call(c.a,c,c.a,b);c.f=!0;return c.a}var d={};b.l=e;b.h=d;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(e,b){for(var d=e.length,a=0;a<d;){for(var c, | ||
f=e,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}}}]); | ||
(function(e){function c(a){if(d[a])return d[a].a;var b=d[a]={m:a,f:!1,a:{}};e[a].call(b.a,b,b.a,c);b.f=!0;return b.a}var d={};c.l=e;c.h=d;c.b=function(a,b){c.c(a)||Object.defineProperty(a,"a",{configurable:!1,enumerable:!0,get:b})};c.i=function(a){var b=a&&a.g?function(){return a["default"]}:function(){return a};c.b(b,b);return b};c.c=function(a){return Object.prototype.hasOwnProperty.call(a,"a")};c.j="";return c(c.o=0)})([function(){window.endianness=function(e,c){for(var d=e.length,a=0;a<d;){for(var b= | ||
e,f=a,g=0,h=c-1,k=parseInt(c/2,10);g<k;){var l=b[f+g];b[f+g]=b[f+h];b[f+h]=l;g++;h--}a+=c}}}]); |
@@ -82,10 +82,3 @@ /******/ (function(modules) { // webpackBootstrap | ||
* @param {!Array<number>|!Array<string>|Uint8Array} bytes The bytes. | ||
* @param {number} offset The byte 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 | ||
* - 7 for 56-bit | ||
* - 8 for 64-bit | ||
* @param {number} offset The number of bytes of each unit of information. | ||
*/ | ||
@@ -96,3 +89,3 @@ function endianness(bytes, offset) { | ||
while (i < len) { | ||
byteSwap(bytes, offset, i); | ||
swap(bytes, offset, i); | ||
i += offset; | ||
@@ -103,17 +96,16 @@ } | ||
/** | ||
* Swap the endianness of a unit of information in a array of bytes. | ||
* Swap the endianness of a unit of information in a byte array. | ||
* The original array is modified in-place. | ||
* @param {!Array<number>|!Array<string>|Uint8Array} bytes The bytes. | ||
* @param {number} offset The number of bytes according to the bit depth. | ||
* @param {number} offset The number of bytes of the unit of information. | ||
* @param {number} index The start index of the unit of information. | ||
*/ | ||
function byteSwap(bytes, offset, index) { | ||
function swap(bytes, offset, index) { | ||
let x = 0; | ||
let y = offset - 1; | ||
let limit = parseInt(offset / 2, 10); | ||
let swap; | ||
while(x < limit) { | ||
swap = bytes[index + x]; | ||
let theByte = bytes[index + x]; | ||
bytes[index + x] = bytes[index + y]; | ||
bytes[index + y] = swap; | ||
bytes[index + y] = theByte; | ||
x++; | ||
@@ -120,0 +112,0 @@ y--; |
@@ -0,0 +0,0 @@ /*global document */ |
@@ -0,0 +0,0 @@ |
PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n"]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]*)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["com", | ||
/^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]); |
@@ -0,0 +0,0 @@ var q=null;window.PR_SHOULD_USE_CONTINUATION=!0; |
22
index.js
@@ -13,10 +13,3 @@ /*! | ||
* @param {!Array<number>|!Array<string>|Uint8Array} bytes The bytes. | ||
* @param {number} offset The byte 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 | ||
* - 7 for 56-bit | ||
* - 8 for 64-bit | ||
* @param {number} offset The number of bytes of each unit of information. | ||
*/ | ||
@@ -27,3 +20,3 @@ function endianness(bytes, offset) { | ||
while (i < len) { | ||
byteSwap(bytes, offset, i); | ||
swap(bytes, offset, i); | ||
i += offset; | ||
@@ -34,17 +27,16 @@ } | ||
/** | ||
* Swap the endianness of a unit of information in a array of bytes. | ||
* Swap the endianness of a unit of information in a byte array. | ||
* The original array is modified in-place. | ||
* @param {!Array<number>|!Array<string>|Uint8Array} bytes The bytes. | ||
* @param {number} offset The number of bytes according to the bit depth. | ||
* @param {number} offset The number of bytes of the unit of information. | ||
* @param {number} index The start index of the unit of information. | ||
*/ | ||
function byteSwap(bytes, offset, index) { | ||
function swap(bytes, offset, index) { | ||
let x = 0; | ||
let y = offset - 1; | ||
let limit = parseInt(offset / 2, 10); | ||
let swap; | ||
while(x < limit) { | ||
swap = bytes[index + x]; | ||
let theByte = bytes[index + x]; | ||
bytes[index + x] = bytes[index + y]; | ||
bytes[index + y] = swap; | ||
bytes[index + y] = theByte; | ||
x++; | ||
@@ -51,0 +43,0 @@ y--; |
{ | ||
"name": "endianness", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "Swap endianness in byte arrays.", | ||
@@ -16,3 +16,5 @@ "homepage": "https://github.com/rochars/endianness", | ||
"endianness", | ||
"swap" | ||
"swap", | ||
"binary", | ||
"network order" | ||
], | ||
@@ -29,3 +31,3 @@ "repository": { | ||
"compile": "google-closure-compiler-js dist/endianness.js > dist/endianness-min.js --compilationLevel=ADVANCED", | ||
"doc": "./node_modules/.bin/jsdoc index.js -d docs", | ||
"doc": "./node_modules/.bin/jsdoc index.js -d docs -r README.md -t node_modules/docdash", | ||
"qa": "npm run lint && npm run test", | ||
@@ -37,2 +39,3 @@ "pack": "npm run bundle && npm run compile && npm run doc", | ||
"codecov": "^3.0.0", | ||
"docdash": "^0.4.0", | ||
"google-closure-compiler-js": "^20170910.0.1", | ||
@@ -48,2 +51,2 @@ "jsdoc": "~3.5.5", | ||
"main": "index.js" | ||
} | ||
} |
@@ -6,3 +6,3 @@ # endianness | ||
[![Travis](https://img.shields.io/travis/rochars/endianness.svg?style=for-the-badge)](https://travis-ci.org/rochars/endianness) [![AppVeyor](https://img.shields.io/appveyor/ci/rochars/endianness.svg?style=for-the-badge&logo=appveyor)](https://ci.appveyor.com/project/rochars/endianness) [![Codecov](https://img.shields.io/codecov/c/github/rochars/endianness.svg?style=for-the-badge)](https://codecov.io/gh/rochars/endianness) [![NPM version](https://img.shields.io/npm/v/endianness.svg?style=for-the-badge)](https://www.npmjs.com/package/endianness) | ||
[![NPM version](https://img.shields.io/npm/v/endianness.svg?style=for-the-badge)](https://www.npmjs.com/package/endianness) [![Docs](https://img.shields.io/badge/docs-online-blue.svg?style=for-the-badge)](https://rochars.github.io/endianness/index.html) | ||
@@ -12,4 +12,5 @@ Swap endianness in byte arrays. | ||
- Works in Node.js and in the browser | ||
- Works with **number arrays**, **string arrays** and **Uint8Array** | ||
- Works with **Array** and **Uint8Array** | ||
- Works with any byte offset | ||
- Bytes can be represented as strings | ||
- The input array is modified in-place. | ||
@@ -41,10 +42,3 @@ | ||
* @param {!Array<number>|!Array<string>|Uint8Array} bytes The bytes. | ||
* @param {number} offset The byte 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 | ||
* - 7 for 56-bit | ||
* - 8 for 64-bit | ||
* @param {number} offset The number of bytes of each unit of information. | ||
*/ | ||
@@ -51,0 +45,0 @@ function endianness(bytes, offset) {} |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 10 instances in 1 package
848
1
63000
10
16
75