New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

imaadpcm

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

imaadpcm - npm Package Compare versions

Comparing version 3.1.0 to 4.0.0-alpha.0

externs.js

4

CHANGELOG.md
# CHANGELOG
## v4.0.0 (2018-07-01)
- Use typed arrays for input and output
-
## v3.1.0 (2018-06-25)

@@ -4,0 +8,0 @@ - Allow better use of this lib as a dependency:

25

dist/imaadpcm.cjs.js

@@ -9,4 +9,7 @@ 'use strict';

*
* Copyright (c) 2017-2018 Rafael da Silva Rocha.
* Derived directly from https://github.com/acida/pyima
* Copyright (c) 2016 acida. MIT License.
*
* Copyright (c) 2018 Rafael da Silva Rocha.
*
* Permission is hereby granted, free of charge, to any person obtaining

@@ -91,8 +94,8 @@ * a copy of this software and associated documentation files (the

* Encode 16-bit PCM samples into 4-bit IMA ADPCM samples.
* @param {!Array<number>} samples A array of samples.
* @return {!Array<number>}
* @param {!Int16Array} samples A array of samples.
* @return {!Uint8Array}
*/
function encode(samples) {
/** @type {!Array<number>} */
let adpcmSamples = [];
/** @type {!Uint8Array} */
let adpcmSamples = new Uint8Array(samples.length);
/** @type {Array<number>} */

@@ -103,3 +106,3 @@ let block = [];

if ((i % 505 == 0 && i != 0) || i == samples.length - 1) {
adpcmSamples = adpcmSamples.concat(encodeBlock(block));
adpcmSamples.set(encodeBlock(block), i - 505);
block = [];

@@ -113,14 +116,14 @@ }

* Decode IMA ADPCM samples into 16-bit PCM samples.
* @param {!Array<number>} adpcmSamples A array of ADPCM samples.
* @param {!Uint8Array} adpcmSamples A array of ADPCM samples.
* @param {number} blockAlign The block size.
* @return {!Array<number>}
* @return {!Int16Array}
*/
function decode(adpcmSamples, blockAlign=256) {
/** @type {!Int16Array} */
let samples = new Int16Array(adpcmSamples.length + blockAlign);
/** @type {!Array<number>} */
let samples = [];
/** @type {!Array<number>} */
let block = [];
for (let i=0; i<adpcmSamples.length; i++) {
if (i % blockAlign == 0 && i != 0) {
samples = samples.concat(decodeBlock(block));
samples.set(decodeBlock(block), i - blockAlign);
block = [];

@@ -127,0 +130,0 @@ }

@@ -5,4 +5,7 @@ /*

*
* Copyright (c) 2017-2018 Rafael da Silva Rocha.
* Derived directly from https://github.com/acida/pyima
* Copyright (c) 2016 acida. MIT License.
*
* Copyright (c) 2018 Rafael da Silva Rocha.
*
* Permission is hereby granted, free of charge, to any person obtaining

@@ -87,8 +90,8 @@ * a copy of this software and associated documentation files (the

* Encode 16-bit PCM samples into 4-bit IMA ADPCM samples.
* @param {!Array<number>} samples A array of samples.
* @return {!Array<number>}
* @param {!Int16Array} samples A array of samples.
* @return {!Uint8Array}
*/
function encode(samples) {
/** @type {!Array<number>} */
let adpcmSamples = [];
/** @type {!Uint8Array} */
let adpcmSamples = new Uint8Array(samples.length);
/** @type {Array<number>} */

@@ -99,3 +102,3 @@ let block = [];

if ((i % 505 == 0 && i != 0) || i == samples.length - 1) {
adpcmSamples = adpcmSamples.concat(encodeBlock(block));
adpcmSamples.set(encodeBlock(block), i - 505);
block = [];

@@ -109,14 +112,14 @@ }

* Decode IMA ADPCM samples into 16-bit PCM samples.
* @param {!Array<number>} adpcmSamples A array of ADPCM samples.
* @param {!Uint8Array} adpcmSamples A array of ADPCM samples.
* @param {number} blockAlign The block size.
* @return {!Array<number>}
* @return {!Int16Array}
*/
function decode(adpcmSamples, blockAlign=256) {
/** @type {!Int16Array} */
let samples = new Int16Array(adpcmSamples.length + blockAlign);
/** @type {!Array<number>} */
let samples = [];
/** @type {!Array<number>} */
let block = [];
for (let i=0; i<adpcmSamples.length; i++) {
if (i % blockAlign == 0 && i != 0) {
samples = samples.concat(decodeBlock(block));
samples.set(decodeBlock(block), i - blockAlign);
block = [];

@@ -123,0 +126,0 @@ }

@@ -1,7 +0,9 @@

var p="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this;function t(){t=function(){};p.Symbol||(p.Symbol=z)}var z=function(){var g=0;return function(a){return"jscomp_symbol_"+(a||"")+g++}}();
window.imaadpcm=function(g){function a(b){if(d[b])return d[b].a;var c=d[b]={m:b,f:!1,a:{}};g[b].call(c.a,c,c.a,a);c.f=!0;return c.a}var d={};a.l=g;a.g=d;a.d=function(b,c,d){a.c(b,c)||Object.defineProperty(b,c,{enumerable:!0,get:d})};a.r=function(b){t();t();"undefined"!==typeof Symbol&&Symbol.toStringTag&&(t(),Object.defineProperty(b,Symbol.toStringTag,{value:"Module"}));Object.defineProperty(b,"__esModule",{value:!0})};a.j=function(b,c){c&1&&(b=a(b));if(c&8)return b;if(c&4&&"object"===typeof b&&b&&
b.b)return b;var d=Object.create(null);a.r(d);Object.defineProperty(d,"default",{enumerable:!0,value:b});if(c&2&&"string"!=typeof b)for(var g in b)a.d(d,g,function(a){return b[a]}.bind(null,g));return d};a.h=function(b){var c=b&&b.b?function(){return b["default"]}:function(){return b};a.d(c,"a",c);return c};a.c=function(b,a){return Object.prototype.hasOwnProperty.call(b,a)};a.i="";return a(a.o=0)}([function(g,a,d){function b(f){for(var e=[],b=[],a=0;a<f.length;a++)if(b.push(f[a]),0==a%505&&0!=a||
a==f.length-1)e=e.concat(u(b)),b=[];return e}function c(f,e){e=void 0===e?256:e;for(var b=[],a=[],c=0;c<f.length;c++)0==c%e&&0!=c&&(b=b.concat(v(a)),a=[]),a.push(f[c]);return b}function u(b){var e=b[0];q(e);var a=[];a.push(e&255);a.push(e>>8&255);a.push(m);a.push(0);for(e=3;e<b.length;e+=2){var f=q(b[e]),c=q(b[e+1]);a.push(c<<4|f)}for(;256>a.length;)a.push(0);return a}function v(a){h=w(a[1]<<8|a[0]);k=a[2];n=r[k];for(var b=[h,w(a[3]<<8|a[2])],c=4;c<a.length;c++){var f=a[c],d=f>>4;b.push(x(d<<4^f));
b.push(x(d))}return b}function w(a){return 32768<a?a-65536:a}function q(a){var b=a-l;0<=b?a=0:(a=8,b=-b);var c=r[m],d=c>>3;b>c&&(a|=4,b-=c,d+=c);c>>=1;b>c&&(a|=2,b-=c,d+=c);c>>=1;b>c&&(a|=1,d+=c);b=a;l=b&8?l-d:l+d;-32768>l?l=-32768:32767<l&&(l=32767);m+=y[b&7];0>m?m=0:88<m&&(m=88);return a}function x(a){var b=0;a&4&&(b+=n);a&2&&(b+=n>>1);a&1&&(b+=n>>2);b+=n>>3;a&8&&(b=-b);h+=b;32767<h?h=32767:-32767>h&&(h=-32767);k+=y[a];0>k?k=0:88<k&&(k=88);n=r[k];return h}d.r(a);d.d(a,"encode",function(){return b});
d.d(a,"decode",function(){return c});d.d(a,"encodeBlock",function(){return u});d.d(a,"decodeBlock",function(){return v});var y=[-1,-1,-1,-1,2,4,6,8,-1,-1,-1,-1,2,4,6,8],r=[7,8,9,10,11,12,13,14,16,17,19,21,23,25,28,31,34,37,41,45,50,55,60,66,73,80,88,97,107,118,130,143,157,173,190,209,230,253,279,307,337,371,408,449,494,544,598,658,724,796,876,963,1060,1166,1282,1411,1552,1707,1878,2066,2272,2499,2749,3024,3327,3660,4026,4428,4871,5358,5894,6484,7132,7845,8630,9493,10442,11487,12635,13899,15289,16818,
18500,20350,22385,24623,27086,29794,32767],l=0,m=0,h=0,k=0,n=7}]);window.imaadpcm=window.imaadpcm;
/*
imaadpcm Copyright (c) 2017-2018 Rafael da Silva Rocha.
Derived directly from https://github.com/acida/pyima
Copyright (c) 2016 acida. MIT License.
*/
window.imaadpcm=function(m){function q(b){var a=b[0];n(a);var c=[];c.push(a&255);c.push(a>>8&255);c.push(k);c.push(0);for(a=3;a<b.length;a+=2){var d=n(b[a]),e=n(b[a+1]);c.push(e<<4|d)}for(;256>c.length;)c.push(0);return c}function r(b){f=t(b[1]<<8|b[0]);g=b[2];l=p[g];for(var a=[f,t(b[3]<<8|b[2])],c=4;c<b.length;c++){var d=b[c],e=d>>4;a.push(u(e<<4^d));a.push(u(e))}return a}function t(b){return 32768<b?b-65536:b}function n(b){var a=b-h;0<=a?b=0:(b=8,a=-a);var c=p[k],d=c>>3;a>c&&(b|=4,a-=c,d+=c);c>>=
1;a>c&&(b|=2,a-=c,d+=c);c>>=1;a>c&&(b|=1,d+=c);a=b;h=a&8?h-d:h+d;-32768>h?h=-32768:32767<h&&(h=32767);k+=v[a&7];0>k?k=0:88<k&&(k=88);return b}function u(b){var a=0;b&4&&(a+=l);b&2&&(a+=l>>1);b&1&&(a+=l>>2);a+=l>>3;b&8&&(a=-a);f+=a;32767<f?f=32767:-32767>f&&(f=-32767);g+=v[b];0>g?g=0:88<g&&(g=88);l=p[g];return f}var v=[-1,-1,-1,-1,2,4,6,8,-1,-1,-1,-1,2,4,6,8],p=[7,8,9,10,11,12,13,14,16,17,19,21,23,25,28,31,34,37,41,45,50,55,60,66,73,80,88,97,107,118,130,143,157,173,190,209,230,253,279,307,337,371,
408,449,494,544,598,658,724,796,876,963,1060,1166,1282,1411,1552,1707,1878,2066,2272,2499,2749,3024,3327,3660,4026,4428,4871,5358,5894,6484,7132,7845,8630,9493,10442,11487,12635,13899,15289,16818,18500,20350,22385,24623,27086,29794,32767],h=0,k=0,f=0,g=0,l=7;m.encode=function(b){for(var a=new Uint8Array(b.length),c=[],d=0;d<b.length;d++)if(c.push(b[d]),0==d%505&&0!=d||d==b.length-1)a.set(q(c),d-505),c=[];return a};m.decode=function(b,a){a=void 0===a?256:a;for(var c=new Int16Array(b.length+a),d=[],
e=0;e<b.length;e++)0==e%a&&0!=e&&(c.set(r(d),e-a),d=[]),d.push(b[e]);return c};m.encodeBlock=q;m.decodeBlock=r;return m}({});

@@ -11,4 +11,7 @@ (function (global, factory) {

*
* Copyright (c) 2017-2018 Rafael da Silva Rocha.
* Derived directly from https://github.com/acida/pyima
* Copyright (c) 2016 acida. MIT License.
*
* Copyright (c) 2018 Rafael da Silva Rocha.
*
* Permission is hereby granted, free of charge, to any person obtaining

@@ -93,8 +96,8 @@ * a copy of this software and associated documentation files (the

* Encode 16-bit PCM samples into 4-bit IMA ADPCM samples.
* @param {!Array<number>} samples A array of samples.
* @return {!Array<number>}
* @param {!Int16Array} samples A array of samples.
* @return {!Uint8Array}
*/
function encode(samples) {
/** @type {!Array<number>} */
let adpcmSamples = [];
/** @type {!Uint8Array} */
let adpcmSamples = new Uint8Array(samples.length);
/** @type {Array<number>} */

@@ -105,3 +108,3 @@ let block = [];

if ((i % 505 == 0 && i != 0) || i == samples.length - 1) {
adpcmSamples = adpcmSamples.concat(encodeBlock(block));
adpcmSamples.set(encodeBlock(block), i - 505);
block = [];

@@ -115,14 +118,14 @@ }

* Decode IMA ADPCM samples into 16-bit PCM samples.
* @param {!Array<number>} adpcmSamples A array of ADPCM samples.
* @param {!Uint8Array} adpcmSamples A array of ADPCM samples.
* @param {number} blockAlign The block size.
* @return {!Array<number>}
* @return {!Int16Array}
*/
function decode(adpcmSamples, blockAlign=256) {
/** @type {!Int16Array} */
let samples = new Int16Array(adpcmSamples.length + blockAlign);
/** @type {!Array<number>} */
let samples = [];
/** @type {!Array<number>} */
let block = [];
for (let i=0; i<adpcmSamples.length; i++) {
if (i % blockAlign == 0 && i != 0) {
samples = samples.concat(decodeBlock(block));
samples.set(decodeBlock(block), i - blockAlign);
block = [];

@@ -129,0 +132,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 imaadpcm```.
This library is a ES6 module also distributed as a CommonJS module, UMD and a compiled script for browsers.
## If you are using this lib in a browser:
- The **CommonJS** is the one used by Node. It is served in the "main" field of package.json
- The **UMD** module is compatible with Node, AMD and browsers. It is served in the "browser" field.
- The **compiled dist** is browser-only and should be the one served by CDNs.
- The **ES6** dist is **imaadpcm.js**, served as "module" in package.json
You may load both **imaadpcm.umd.js** and **imaadpcm.min.js** in the browser with ```<script>``` tags. Ideally you should use **imaadpcm.min.js**. You can load it via the https://unpkg.com and https://www.jsdelivr.com/ CDNs:
You may load both **imaadpcm.umd.js** and **imaadpcm.min.js** in the browser with ```<script>``` tags.
[unpkg](https://www.unpkg.com):
```html
<script src="https://unpkg.com/imaadpcm"></script>
```
[jsDelivr](https://www.jsdelivr.com):
```html
<script src="https://cdn.jsdelivr.net/npm/imaadpcm"></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. 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 imaadpcm**.
- 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 **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 **ES6 dist** is **imaadpcm.js**, served as "es2015" in package.json. It includes all the dependencies. 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).
If your module bundler is using "browser" as the entry point **your dist should work the same** but will be a larger file.
## LICENSE
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.

@@ -5,4 +5,7 @@ /*

*
* Copyright (c) 2017-2018 Rafael da Silva Rocha.
* Derived directly from https://github.com/acida/pyima
* Copyright (c) 2016 acida. MIT License.
*
* Copyright (c) 2018 Rafael da Silva Rocha.
*
* Permission is hereby granted, free of charge, to any person obtaining

@@ -92,8 +95,8 @@ * a copy of this software and associated documentation files (the

* Encode 16-bit PCM samples into 4-bit IMA ADPCM samples.
* @param {!Array<number>} samples A array of samples.
* @return {!Array<number>}
* @param {!Int16Array} samples A array of samples.
* @return {!Uint8Array}
*/
export function encode(samples) {
/** @type {!Array<number>} */
let adpcmSamples = [];
/** @type {!Uint8Array} */
let adpcmSamples = new Uint8Array(samples.length);
/** @type {Array<number>} */

@@ -104,3 +107,3 @@ let block = [];

if ((i % 505 == 0 && i != 0) || i == samples.length - 1) {
adpcmSamples = adpcmSamples.concat(encodeBlock(block));
adpcmSamples.set(encodeBlock(block), i - 505);
block = [];

@@ -114,14 +117,14 @@ }

* Decode IMA ADPCM samples into 16-bit PCM samples.
* @param {!Array<number>} adpcmSamples A array of ADPCM samples.
* @param {!Uint8Array} adpcmSamples A array of ADPCM samples.
* @param {number} blockAlign The block size.
* @return {!Array<number>}
* @return {!Int16Array}
*/
export function decode(adpcmSamples, blockAlign=256) {
/** @type {!Int16Array} */
let samples = new Int16Array(adpcmSamples.length + blockAlign);
/** @type {!Array<number>} */
let samples = [];
/** @type {!Array<number>} */
let block = [];
for (let i=0; i<adpcmSamples.length; i++) {
if (i % blockAlign == 0 && i != 0) {
samples = samples.concat(decodeBlock(block));
samples.set(decodeBlock(block), i - blockAlign);
block = [];

@@ -128,0 +131,0 @@ }

{
"name": "imaadpcm",
"version": "3.1.0",
"version": "4.0.0-alpha.0",
"description": "IMA ADPCM codec in JavaScript.",

@@ -14,2 +14,3 @@ "homepage": "https://github.com/rochars/imaadpcm",

"unpkg": "./dist/imaadpcm.min.js",
"types": "./index.d.ts",
"engines": {

@@ -46,3 +47,3 @@ "node": ">=8"

"test-dist": "npm run test-min && npm run test-cjs && npm run test-umd && npm run test-esm",
"pack": "rollup --config && webpack && npm run test-dist && npm run test",
"pack": "rollup --config && npm run test-dist && npm run test",
"doc": "./node_modules/.bin/jsdoc index.js -d docs -r README.md -t node_modules/docdash",

@@ -65,7 +66,6 @@ "build": "npm run lint && npm run pack && npm run doc",

"rollup": "^0.61.2",
"rollup-plugin-closure-compiler-js": "^1.0.6",
"rollup-plugin-commonjs": "^9.1.3",
"rollup-plugin-node-resolve": "^3.3.0",
"webpack": "^4.12.1",
"webpack-cli": "^3.0.8"
"rollup-plugin-node-resolve": "^3.3.0"
}
}

@@ -25,2 +25,3 @@ # imaadpcm

### Node
Require imaadpcm from "imaadpcm":
```javascript

@@ -56,3 +57,3 @@ const imaadpcm = require("imaadpcm");

<script type="module">
import imaadpcm from 'https://dev.jspm.io/imaadpcm';
import * as imaadpcm from 'https://dev.jspm.io/imaadpcm';
// ...

@@ -131,12 +132,2 @@ </script>

## Distribution
This library is a ES6 module also distributed as a CommonJS module, UMD and a compiled script for browsers.
- The **CommonJS** is the one used by Node. It is served in the "main" field of package.json
- The **UMD** module is compatible with Node, AMD and browsers. It is served in the "browser" field.
- The **compiled dist** is browser-only and should be the one served by CDNs.
- The **ES6** dist is **imaadpcm.js**, served as "module" in package.json
You may load both **imaadpcm.umd.js** and **imaadpcm.min.js** in the browser with ```<script>``` tags.
## References

@@ -143,0 +134,0 @@ http://www.cs.columbia.edu/~hgs/audio/dvi/

/*
* https://github.com/rochars/byte-data
* Copyright (c) 2017-2018 Rafael da Silva Rocha.
* https://github.com/rochars/imaadpcm
* Copyright (c) 2018 Rafael da Silva Rocha.
*/

@@ -12,3 +12,15 @@

import nodeResolve from 'rollup-plugin-node-resolve';
import closure from 'rollup-plugin-closure-compiler-js';
// Read externs definitions
const fs = require('fs');
let externsSrc = fs.readFileSync('./externs.js', 'utf8');
// License notes for bundles that include dependencies
const license = '/*!\n'+
' * imaadpcm Copyright (c) 2017-2018 Rafael da Silva Rocha.\n'+
' * Derived directly from https://github.com/acida/pyima\n' +
' * Copyright (c) 2016 acida. MIT License.\n' +
' */\n';
export default [

@@ -27,6 +39,6 @@ // cjs

nodeResolve(),
commonjs(),
commonjs()
]
},
// umd
// umd, es
{

@@ -38,3 +50,7 @@ input: 'index.js',

name: 'imaadpcm',
format: 'umd',
format: 'umd'
},
{
file: 'dist/imaadpcm.js',
format: 'es'
}

@@ -44,6 +60,6 @@ ],

nodeResolve(),
commonjs(),
commonjs()
]
},
// esm
// browser
{

@@ -53,4 +69,7 @@ input: 'index.js',

{
file: 'dist/imaadpcm.js',
format: 'es',
name: 'imaadpcm',
format: 'iife',
file: 'dist/imaadpcm.min.js',
banner: license,
footer: 'window["imaadpcm"]=imaadpcm;'
}

@@ -61,4 +80,11 @@ ],

commonjs(),
closure({
languageIn: 'ECMASCRIPT6',
languageOut: 'ECMASCRIPT5',
compilationLevel: 'ADVANCED',
warningLevel: 'VERBOSE',
externs: [{src:externsSrc}]
})
]
}
];
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