Socket
Socket
Sign inDemoInstall

endianness

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

endianness - npm Package Compare versions

Comparing version 7.0.1 to 7.0.2

3

CHANGELOG.md
# CHANGELOG
## version 7.0.2 (2018-07-06)
- Fix: make 'offset' param not optional in index.d.ts
## version 7.0.1 (2018-07-03)

@@ -4,0 +7,0 @@ - Smaller browser dist file (312 bytes)

15

dist/endianness.cjs.js
'use strict';
/*
* endianness: Swap endianness in byte arrays.
* https://github.com/rochars/endianness
*
* Copyright (c) 2017-2018 Rafael da Silva Rocha.

@@ -32,2 +29,3 @@ *

* @fileoverview A function to swap endianness in byte buffers.
* @see https://github.com/rochars/endianness
*/

@@ -43,7 +41,7 @@

* @param {number} offset The byte offset.
* @param {number=} start The start index. Assumes 0.
* @param {number=} index 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, start=0, end=null) {
function endianness(bytes, offset, index=0, end=null) {
let len = end || bytes.length;

@@ -54,6 +52,5 @@ let limit = parseInt(offset / 2, 10);

}
let i = start;
while (i < len) {
swap(bytes, offset, i, limit);
i += offset;
while (index < len) {
swap(bytes, offset, index, limit);
index += offset;
}

@@ -60,0 +57,0 @@ }

/*
* endianness: Swap endianness in byte arrays.
* https://github.com/rochars/endianness
*
* Copyright (c) 2017-2018 Rafael da Silva Rocha.

@@ -30,2 +27,3 @@ *

* @fileoverview A function to swap endianness in byte buffers.
* @see https://github.com/rochars/endianness
*/

@@ -41,7 +39,7 @@

* @param {number} offset The byte offset.
* @param {number=} start The start index. Assumes 0.
* @param {number=} index 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, start=0, end=null) {
function endianness(bytes, offset, index=0, end=null) {
let len = end || bytes.length;

@@ -52,6 +50,5 @@ let limit = parseInt(offset / 2, 10);

}
let i = start;
while (i < len) {
swap(bytes, offset, i, limit);
i += offset;
while (index < len) {
swap(bytes, offset, index, limit);
index += offset;
}

@@ -58,0 +55,0 @@ }

/*
endianness Copyright (c) 2017-2018 Rafael da Silva Rocha.
*/
window.endianness=function(h,c,a,b){b=(void 0===b?null:b)||h.length;var k=parseInt(c/2,10);if(b%c)throw Error("Bad buffer length.");for(a=void 0===a?0:a;a<b;){for(var d=h,e=a,l=k,f=0,g=c-1;f<l;){var m=d[e+f];d[e+f]=d[e+g];d[e+g]=m;f++;g--}a+=c}};
window.endianness=function(h,c,a,b){a=void 0===a?0:a;b=(void 0===b?null:b)||h.length;var k=parseInt(c/2,10);if(b%c)throw Error("Bad buffer length.");for(;a<b;){for(var d=h,e=a,l=k,f=0,g=c-1;f<l;){var m=d[e+f];d[e+f]=d[e+g];d[e+g]=m;f++;g--}a+=c}};

@@ -8,5 +8,2 @@ (function (global, factory) {

/*
* endianness: Swap endianness in byte arrays.
* https://github.com/rochars/endianness
*
* Copyright (c) 2017-2018 Rafael da Silva Rocha.

@@ -37,2 +34,3 @@ *

* @fileoverview A function to swap endianness in byte buffers.
* @see https://github.com/rochars/endianness
*/

@@ -48,7 +46,7 @@

* @param {number} offset The byte offset.
* @param {number=} start The start index. Assumes 0.
* @param {number=} index 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, start=0, end=null) {
function endianness(bytes, offset, index=0, end=null) {
let len = end || bytes.length;

@@ -59,6 +57,5 @@ let limit = parseInt(offset / 2, 10);

}
let i = start;
while (i < len) {
swap(bytes, offset, i, limit);
i += offset;
while (index < len) {
swap(bytes, offset, index, limit);
index += offset;
}

@@ -65,0 +62,0 @@ }

# Distribution
This library is a ES6 module also distributed as a CommonJS module, UMD module and a compiled script for browsers. It works out of the box in Node when installed with ```npm install endianness```.
This library is a ES module also distributed as a CommonJS module, UMD module and a compiled script for browsers. It works out of the box in Node when installed with ```npm install endianness```. It includes a TypeScript definition file.
If you use the [Closure Compiler](https://github.com/google/closure-compiler), this package includes a externs file: **./externs.js**.
## If you are using this lib in a browser:
You may load both **endianness.umd.js** and **endianness.min.js** in the browser with ```<script>``` tags. Ideally you should use **endianness.min.js**. You can load it via the https://unpkg.com and https://www.jsdelivr.com/ CDNs:
You may load both **./dist/endianness.umd.js** and **./dist/endianness.min.js** in the browser with ```<script>``` tags. Ideally you should use **endianness.min.js**. You can load it via the https://unpkg.com and https://www.jsdelivr.com/ CDNs:
[unpkg](https://www.unpkg.com/endianness):
[unpkg](https://unpkg.com/endianness):
```html

@@ -13,3 +15,3 @@ <script src="https://unpkg.com/endianness"></script>

[jsDelivr](https://www.jsdelivr.com/npm/endianness):
[jsDelivr](https://cdn.jsdelivr.net/npm/endianness):
```html

@@ -21,11 +23,11 @@ <script src="https://cdn.jsdelivr.net/npm/endianness"></script>

- The **CommonJS** is the dist file used by Node. It is served in the "main" field of package.json. It includes all the sources but no dependencies. Dependencies will be imported from the **node_modules** folder. This is the source you are running when you **npm install endianness**.
- The **CommonJS** is the dist file used by Node. It is served in the "main" field of package.json. This is the source you are running when you **npm install endianness**.
- The **UMD** module is compatible with Node, AMD and browsers. It is served in the "browser" field of package.json. It includes all dependencies. This file is not compiled/minified as it may be used by module bundlers. Compilation/minification should be up to the bundler consuming this file.
- The **UMD** module is compatible with Node, AMD and browsers. It is served in the "browser" field of package.json. This file is not compiled/minified as it may be used by module bundlers. Compilation/minification should be up to the bundler consuming this file.
- The **compiled dist** is browser-only and should be the one served by CDNs. It includes all the dependencies. It is used in the "unpkg" and "jsdelivr" fields of package.json.
- The **compiled dist** is browser-only and should be the one served by CDNs. It is used in the "unpkg" and "jsdelivr" fields of package.json.
- The **ES6 dist** is **endianness.js**, served as "es2015" in package.json. It includes all the dependencies. It is not compiled/minified.
- The **ES6 dist** is **./dist/endianness.js**, served as "es2015" in package.json. It is not compiled/minified.
- **./index.js** is served as "module" in package.json. It should be used by systems that support ES modules and are aware of Node's module path resolution (a module bundler, for instance). This should be the entry point for bundlers in most cases - this will avoid code duplication in the case of shared dependencies (as opposed to using "browser" as the entry point).
- **./index.js** is served as "module" in package.json. This should be the entry point for bundlers.

@@ -32,0 +34,0 @@ If your module bundler is using "browser" as the entry point **your dist should work the same** but will be a larger file.

@@ -6,2 +6,2 @@ // Type definitions for endianness 7.0

export default function endianness(bytes: Array<number|string>|Uint8Array, offset?: number, start?: number, end?: number): void;
export default function endianness(bytes: Array<number|string>|Uint8Array, offset: number, start?: number, end?: number): void;
/*
* endianness: Swap endianness in byte arrays.
* https://github.com/rochars/endianness
*
* Copyright (c) 2017-2018 Rafael da Silva Rocha.

@@ -30,2 +27,3 @@ *

* @fileoverview A function to swap endianness in byte buffers.
* @see https://github.com/rochars/endianness
*/

@@ -41,7 +39,7 @@

* @param {number} offset The byte offset.
* @param {number=} start The start index. Assumes 0.
* @param {number=} index The start index. Assumes 0.
* @param {?number=} end The end index. Assumes the buffer length.
* @throws {Error} If the buffer length is not valid.
*/
export default function endianness(bytes, offset, start=0, end=null) {
export default function endianness(bytes, offset, index=0, end=null) {
let len = end || bytes.length;

@@ -52,6 +50,5 @@ let limit = parseInt(offset / 2, 10);

}
let i = start;
while (i < len) {
swap(bytes, offset, i, limit);
i += offset;
while (index < len) {
swap(bytes, offset, index, limit);
index += offset;
}

@@ -58,0 +55,0 @@ }

{
"name": "endianness",
"version": "7.0.1",
"version": "7.0.2",
"description": "Swap endianness in byte arrays.",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/rochars/endianness",

@@ -5,3 +5,3 @@ # 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)
[![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) [![Tests](https://img.shields.io/badge/tests-online-blue.svg?style=for-the-badge)](https://rawgit.com/rochars/endianness/master/test/browser.html)
[![Codecov](https://img.shields.io/codecov/c/github/rochars/endianness.svg?style=flat-square)](https://codecov.io/gh/rochars/endianness) [![Unix Build](https://img.shields.io/travis/rochars/endianness.svg?style=flat-square)](https://travis-ci.org/rochars/endianness) [![Windows Build](https://img.shields.io/appveyor/ci/rochars/endianness.svg?style=flat-square&logo=appveyor)](https://ci.appveyor.com/project/rochars/endianness) [![Scrutinizer](https://img.shields.io/scrutinizer/g/rochars/endianness.svg?style=flat-square&logo=scrutinizer)](https://scrutinizer-ci.com/g/rochars/endianness/)

@@ -23,5 +23,5 @@

### ES6
```import``` endianness from **endianness.js**:
```import``` endianness from **./dist/endianness.js**:
```javascript
import endianness from 'endianness.js';
import endianness from './dist/endianness.js';

@@ -46,3 +46,3 @@ // Swap endianness of one 64-bit value:

```html
<script src="endianness.min.js"></script>
<script src="./dist/endianness.min.js"></script>
<script>

@@ -85,2 +85,35 @@ var bytes = [64, 9, 33, 251, 84, 68, 45, 24];

## Distribution
This library is a ES module also distributed as a CommonJS module, UMD module and a compiled script for browsers. It works out of the box in Node when installed with ```npm install endianness```. It includes a TypeScript definition file.
If you use the [Closure Compiler](https://github.com/google/closure-compiler), this package includes a externs file: **./externs.js**.
### If you are using this lib in a browser:
You may load both **./dist/endianness.umd.js** and **./dist/endianness.min.js** in the browser with ```<script>``` tags. Ideally you should use **endianness.min.js**. You can load it via the https://unpkg.com and https://www.jsdelivr.com/ CDNs:
[unpkg](https://unpkg.com/endianness):
```html
<script src="https://unpkg.com/endianness"></script>
```
[jsDelivr](https://cdn.jsdelivr.net/npm/endianness):
```html
<script src="https://cdn.jsdelivr.net/npm/endianness"></script>
```
### If you are using this lib as a dependency:
- The **CommonJS** is the dist file used by Node. It is served in the "main" field of package.json. This is the source you are running when you **npm install endianness**.
- The **UMD** module is compatible with Node, AMD and browsers. It is served in the "browser" field of package.json. This file is not compiled/minified as it may be used by module bundlers. Compilation/minification should be up to the bundler consuming this file.
- The **compiled dist** is browser-only and should be the one served by CDNs. It is used in the "unpkg" and "jsdelivr" fields of package.json.
- The **ES6 dist** is **./dist/endianness.js**, served as "es2015" in package.json. It is not compiled/minified.
- **./index.js** is served as "module" in package.json. This should be the entry point for bundlers.
If your module bundler is using "browser" as the entry point **your dist should work the same** but will be a larger file.
## LICENSE

@@ -87,0 +120,0 @@ Copyright (c) 2017-2018 Rafael da Silva Rocha.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc