endianness
Advanced tools
Comparing version 6.0.0-alpha.0 to 6.0.0-alpha.2
@@ -1,2 +0,2 @@ | ||
var k=window,l=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(e,b){Object.defineProperty(b,"__esModule",{value:!0}); | ||
b.endianness=function(b,a){var c=b.length;if(c%a)throw Error("Not enough bytes.");for(var d=0;d<c;){for(var f=b,g=d,h=0,e=a-1,n=parseInt(a/2,10);h<n;){var p=f[g+h];f[g+h]=f[g+e];f[g+e]=p;h++;e--}d+=a}}}]),m;for(m in l)k[m]=l[m]; | ||
window.endianness=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(e,b){Object.defineProperty(b,"__esModule",{value:!0}); | ||
b.endianness=function(b,a){var c=b.length;if(c%a)throw Error("Not enough bytes.");for(var d=0;d<c;){for(var f=b,g=d,h=0,e=a-1,k=parseInt(a/2,10);h<k;){var l=f[g+h];f[g+h]=f[g+e];f[g+e]=l;h++;e--}d+=a}}}]); |
@@ -1,14 +0,159 @@ | ||
(function webpackUniversalModuleDefinition(root,factory){if(typeof exports==="object"&&typeof module==="object")module.exports=factory();else if(typeof define==="function"&&define.amd)define([],factory);else{var a=factory();for(var i in a)(typeof exports==="object"?exports:root)[i]=a[i]}})(typeof self!=="undefined"?self:this,function(){return function(modules){var installedModules={};function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module= | ||
installedModules[moduleId]={i:moduleId,l:false,exports:{}};modules[moduleId].call(module.exports,module,module.exports,__webpack_require__);module.l=true;return module.exports}__webpack_require__.m=modules;__webpack_require__.c=installedModules;__webpack_require__.d=function(exports,name,getter){if(!__webpack_require__.o(exports,name))Object.defineProperty(exports,name,{configurable:false,enumerable:true,get:getter})};__webpack_require__.n=function(module){var getter=module&&module.__esModule?function getDefault(){return module["default"]}: | ||
function getModuleExports(){return module};__webpack_require__.d(getter,"a",getter);return getter};__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)};__webpack_require__.p="";return __webpack_require__(__webpack_require__.s=0)}([function(module,__webpack_exports__,__webpack_require__){Object.defineProperty(__webpack_exports__,"__esModule",{value:true});__webpack_exports__["endianness"]=endianness;/** | ||
@param {(!Array<(number|string)>|!Uint8Array)} bytes | ||
@param {number} offset | ||
@throws {Error} | ||
(function webpackUniversalModuleDefinition(root, factory) { | ||
if(typeof exports === 'object' && typeof module === 'object') | ||
module.exports = factory(); | ||
else if(typeof define === 'function' && define.amd) | ||
define([], factory); | ||
else if(typeof exports === 'object') | ||
exports["endianness"] = factory(); | ||
else | ||
root["endianness"] = factory(); | ||
})(typeof self !== 'undefined' ? self : this, function() { | ||
return /******/ (function(modules) { // webpackBootstrap | ||
/******/ // The module cache | ||
/******/ var installedModules = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) { | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ } | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ i: moduleId, | ||
/******/ l: false, | ||
/******/ exports: {} | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Flag the module as loaded | ||
/******/ module.l = true; | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/******/ | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ | ||
/******/ // define getter function for harmony exports | ||
/******/ __webpack_require__.d = function(exports, name, getter) { | ||
/******/ if(!__webpack_require__.o(exports, name)) { | ||
/******/ Object.defineProperty(exports, name, { | ||
/******/ configurable: false, | ||
/******/ enumerable: true, | ||
/******/ get: getter | ||
/******/ }); | ||
/******/ } | ||
/******/ }; | ||
/******/ | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
/******/ __webpack_require__.n = function(module) { | ||
/******/ var getter = module && module.__esModule ? | ||
/******/ function getDefault() { return module['default']; } : | ||
/******/ function getModuleExports() { return module; }; | ||
/******/ __webpack_require__.d(getter, 'a', getter); | ||
/******/ return getter; | ||
/******/ }; | ||
/******/ | ||
/******/ // Object.prototype.hasOwnProperty.call | ||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; | ||
/******/ | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(__webpack_require__.s = 0); | ||
/******/ }) | ||
/************************************************************************/ | ||
/******/ ([ | ||
/* 0 */ | ||
/***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
"use strict"; | ||
Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); | ||
/* harmony export (immutable) */ __webpack_exports__["endianness"] = endianness; | ||
/* | ||
* endianness: Swap endianness in byte arrays. | ||
* https://github.com/rochars/endianness | ||
* | ||
* 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. | ||
* | ||
*/ | ||
function endianness(bytes,offset){var len=bytes.length;if(len%offset)throw new Error("Not enough bytes.");var i=0;while(i<len){swap(bytes,offset,i);i+=offset}}/** | ||
@private | ||
@param {(!Array<(number|string)>|!Uint8Array)} bytes | ||
@param {number} offset | ||
@param {number} index | ||
/** | ||
* @fileoverview A function to swap endianness in byte buffers. | ||
*/ | ||
function swap(bytes,offset,index){var x=0;var y=offset-1;var limit=parseInt(offset/2,10);while(x<limit){var theByte=bytes[index+x];bytes[index+x]=bytes[index+y];bytes[index+y]=theByte;x++;y--}}}])}); | ||
/** | ||
* @module endianness | ||
*/ | ||
/** | ||
* Swap the byte ordering in a buffer. The buffer is modified in place. | ||
* @param {!Array<number|string>|!Uint8Array} bytes The bytes. | ||
* @param {number} offset The byte offset. | ||
* @throws {Error} If the buffer length is not valid. | ||
*/ | ||
function endianness(bytes, offset) { | ||
let len = bytes.length; | ||
if (len % offset) { | ||
throw new Error("Not enough bytes."); | ||
} | ||
let i = 0; | ||
while (i < len) { | ||
swap(bytes, offset, i); | ||
i += offset; | ||
} | ||
} | ||
/** | ||
* Swap the byte order of a value in a buffer. The buffer is modified in place. | ||
* @param {!Array<number|string>|!Uint8Array} bytes The bytes. | ||
* @param {number} offset The byte offset. | ||
* @param {number} index The start index. | ||
* @private | ||
*/ | ||
function swap(bytes, offset, index) { | ||
let x = 0; | ||
let y = offset - 1; | ||
let limit = parseInt(offset / 2, 10); | ||
while(x < limit) { | ||
let theByte = bytes[index + x]; | ||
bytes[index + x] = bytes[index + y]; | ||
bytes[index + y] = theByte; | ||
x++; | ||
y--; | ||
} | ||
} | ||
/***/ }) | ||
/******/ ]); | ||
}); |
{ | ||
"name": "endianness", | ||
"version": "6.0.0-alpha.0", | ||
"version": "6.0.0-alpha.2", | ||
"description": "Swap endianness in byte arrays.", | ||
@@ -8,6 +8,9 @@ "homepage": "https://github.com/rochars/endianness", | ||
"license": "MIT", | ||
"main": "./dist/endianness.umd.js", | ||
"module": "./dist/endianness.esm.js", | ||
"browser": { | ||
"./dist/endianness.umd.js": "./dist/endianness.min.js" | ||
"main": "./dist/endianness.cjs.js", | ||
"module": "./index.js", | ||
"browser": "./dist/endianness.umd.js", | ||
"jsdelivr": "./dist/endianness.min.js", | ||
"unpkg": "./dist/endianness.min.js", | ||
"engines": { | ||
"node": ">=7" | ||
}, | ||
@@ -32,11 +35,11 @@ "keywords": [ | ||
"scripts": { | ||
"lint": "jshint index.js", | ||
"pack": "webpack && npm run test && npm run test-browser", | ||
"test": "nyc ./node_modules/mocha/bin/_mocha test --src --recursive", | ||
"lint": "jshint index.js && jshint test", | ||
"test": "node -r esm ./node_modules/mocha/bin/_mocha test --recursive", | ||
"test-min": "nyc ./node_modules/mocha/bin/_mocha test --min --recursive", | ||
"test-cjs": "nyc ./node_modules/mocha/bin/_mocha test --cjs --recursive", | ||
"test-umd": "nyc ./node_modules/mocha/bin/_mocha test --umd --recursive", | ||
"test-browser": "nyc ./node_modules/mocha/bin/_mocha test --browser --recursive", | ||
"coverage": "nyc report --reporter=lcov > coverage.lcov && codecov", | ||
"doc": "./node_modules/.bin/jsdoc index.js -d docs -r README.md -t node_modules/docdash", | ||
"build": "npm run lint && npm run compile-esm && npm run pack && npm run doc", | ||
"compile-esm": "google-closure-compiler-js --languageIn=ECMASCRIPT6 --languageOut=ECMASCRIPT6 --compilationLevel=WHITESPACE_ONLY --warningLevel=VERBOSE index.js > ./dist/endianness.esm.js", | ||
"coverage": "nyc report --reporter=lcov > coverage.lcov && codecov" | ||
"pack": "npm test && webpack && npm run test-min && npm run test-cjs && npm run test-umd", | ||
"build": "npm run lint && npm run pack && npm run doc" | ||
}, | ||
@@ -48,2 +51,3 @@ "devDependencies": { | ||
"docdash": "^0.4.0", | ||
"esm": "^3.0.51", | ||
"google-closure-compiler-js": "^20180610.0.0", | ||
@@ -50,0 +54,0 @@ "jsdoc": "~3.5.5", |
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
20232
361
12
8
1