Skip to content

Commit

Permalink
Update package structure
Browse files Browse the repository at this point in the history
- dist file is "./dist/alawmulaw.js", served as "main"
- ES6 source is "./index.js", served as "module"
  • Loading branch information
rochars committed Dec 31, 2019
1 parent 7ce36a4 commit 656f3de
Show file tree
Hide file tree
Showing 39 changed files with 4,718 additions and 4,750 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
*.log
*.reapeaks
*.DS_Store
.nyc_output
node_modules
7 changes: 7 additions & 0 deletions .jsdocrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"templates": {
"default": {
"includeDate": false
}
}
}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

## 6.0.0 - 2019-12-31
- New package structure:
* dist file is "./dist/alawmulaw.js", a UMD served as "main"
* ES6 source is "./index.js", served as "module"

## v5.0.2 (2018-07-08)
- Fix: UMD dist for browsers.

Expand Down
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2018 Rafael da Silva Rocha.
Copyright (c) 2018-2019 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
Expand All @@ -17,4 +17,4 @@ 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.
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
72 changes: 12 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# alawmulaw
Copyright (c) 2018 Rafael da Silva Rocha.
Copyright (c) 2018-2019 Rafael da Silva Rocha.
https://github.com/rochars/alawmulaw

[![NPM version](https://img.shields.io/npm/v/alawmulaw.svg?style=for-the-badge)](https://www.npmjs.com/package/alawmulaw) [![Docs](https://img.shields.io/badge/docs-online-blue.svg?style=for-the-badge)](https://rochars.github.io/alawmulaw/index.html) [![Tests](https://img.shields.io/badge/tests-online-blue.svg?style=for-the-badge)](https://rawgit.com/rochars/alawmulaw/master/test/browser.html)
Expand All @@ -14,27 +14,10 @@ npm install alawmulaw

## Use

### Node
Require from 'alawmulaw'
```javascript
const alawmulaw = require('alawmulaw');

// Encode all the samples in a file
// Only 16-bit samples are supported
let aLawSamples = alawmulaw.alaw.encode(pcmSamples);
```

### ES module
Import from **alawmulaw.js**:
```javascript
import * as alawmulaw from './dist/alawmulaw.js';
let aLawSamples = alawmulaw.alaw.encode(pcmSamples);
```

### Browser
Use the compiled file in the */dist* folder:
Use the **alawmulaw.js** file in the */dist* folder:
```html
<script src="./dist/alawmulaw.min.js"></script>
<script src="alawmulaw.js"></script>
<script>
// A-Law
samples = alawmulaw.alaw.encode(samples);
Expand All @@ -60,12 +43,14 @@ Or get it from [unpkg](https://www.unpkg.com):
<script src="https://unpkg.com/alawmulaw"></script>
```

Or as a ES6 module in modern browsers from [jspm](https://jspm.io):
```html
<script type="module">
import * as alawmulaw from 'https://dev.jspm.io/alawmulaw';
// ...
</script>
### Node
Require from 'alawmulaw'
```javascript
const alawmulaw = require('alawmulaw');

// Encode all the samples in a file
// Only 16-bit samples are supported
let aLawSamples = alawmulaw.alaw.encode(pcmSamples);
```

## API
Expand Down Expand Up @@ -133,46 +118,13 @@ export function encode(samples) {}
export function decode(samples) {}
```

## 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 alawmulaw```. 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/alawmulaw.umd.js** and **./dist/alawmulaw.min.js** in the browser with ```<script>``` tags. Ideally you should use **alawmulaw.min.js**. You can load it via the https://unpkg.com and https://www.jsdelivr.com/ CDNs:

[unpkg](https://unpkg.com/alawmulaw):
```html
<script src="https://unpkg.com/alawmulaw"></script>
```

[jsDelivr](https://cdn.jsdelivr.net/npm/alawmulaw):
```html
<script src="https://cdn.jsdelivr.net/npm/alawmulaw"></script>
```

### If you are using this lib as a dependency:

- The **CommonJS** dist is **./dist/alawmulaw.cjs.js**. It is the dist file used by Node. It is served in the "main" field of package.json and is the source you are running when you **npm install alawmulaw**. It is not compiled or minified.

- The **UMD** module is **./dist/alawmulaw.umd.js**. It is transpiled to ES5 and compatible with Node, AMD and browsers. It is served in the "browser" field of package.json.

- The **browser-only** dist is **./dist/alawmulaw.min.js**. It is transpiled to ES5 and compiled. It is used in the "unpkg" and "jsdelivr" fields of package.json.

- The **ES6 dist** is **./dist/alawmulaw.js**, served as "es2015" in package.json. It is not compiled/minified.

- **./main.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.

## References
https://github.com/torvalds/linux/blob/master/sound/core/oss/mulaw.c
https://github.com/deftio/companders
http://dystopiancode.blogspot.com.br/2012/02/pcm-law-and-u-law-companding-algorithms.html

### LICENSE
Copyright (c) 2018 Rafael da Silva Rocha.
Copyright (c) 2018-2019 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
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ environment:
- nodejs_version: "8"
- nodejs_version: "9"
- nodejs_version: "10"
- nodejs_version: "12"

install:
- ps: Install-Product node $env:nodejs_version
Expand Down
54 changes: 0 additions & 54 deletions dist/README.md

This file was deleted.

Loading

0 comments on commit 656f3de

Please sign in to comment.