Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsfx.js can be used as both an IIFE and a node module #15

Merged
merged 2 commits into from Jan 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 17 additions & 7 deletions jsfx.js
@@ -1,4 +1,10 @@
(function(jsfx){
(function(root, factory) {
if (typeof module === "object" && typeof module.exports === "object") {
module.exports = factory();
} else {
root.jsfx = factory();
}
}(this, function() {
'use strict';

var chr = String.fromCharCode;
Expand All @@ -10,6 +16,8 @@
var abs = Math.abs;
var EPSILON = 0.000001;

var jsfx = {};

jsfx.SampleRate = 0|0;
jsfx.Sec = 0|0;

Expand Down Expand Up @@ -1083,11 +1091,11 @@
// uniform random
function runif(scale, offset){
var a = Math.random();
if(scale !== undefined)
a *= scale;
if(offset !== undefined)
a += offset;
return a;
if(scale !== undefined)
a *= scale;
if(offset !== undefined)
a += offset;
return a;
}

function rchoose(gens){
Expand Down Expand Up @@ -1120,4 +1128,6 @@
}
return new Uint8Array(N);
}
})(this.jsfx = {});

return jsfx;
}));
25 changes: 25 additions & 0 deletions package.json
@@ -0,0 +1,25 @@
{
"name": "jsfx-audio",
"version": "1.0.0",
"description": "This is a JavaScript library for sound effect generation and is supported on most current browsers.",
"main": "jsfx.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/loov/jsfx.git"
},
"keywords": [
"audio",
"sound",
"effects",
"jsfx"
],
"author": "loov",
"license": "MIT",
"bugs": {
"url": "https://github.com/loov/jsfx/issues"
},
"homepage": "https://github.com/loov/jsfx#readme"
}