Skip to content

Preserve reference to global this. #43

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions dsp.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,19 @@ var DSP = {
TWO_PI: 2*Math.PI
};


var self = this;
// Setup arrays for platforms which do not support byte arrays
function setupTypedArray(name, fallback) {
// check if TypedArray exists
// typeof on Minefield and Chrome return function, typeof on Webkit returns object.
if (typeof this[name] !== "function" && typeof this[name] !== "object") {
if (typeof self[name] !== "function" && typeof self[name] !== "object") {
// nope.. check if WebGLArray exists
if (typeof this[fallback] === "function" && typeof this[fallback] !== "object") {
this[name] = this[fallback];
if (typeof self[fallback] === "function" && typeof self[fallback] !== "object") {
self[name] = self[fallback];
} else {
// nope.. set as Native JS array
this[name] = function(obj) {
self[name] = function(obj) {
if (obj instanceof Array) {
return obj;
} else if (typeof obj === "number") {
Expand Down Expand Up @@ -2300,7 +2302,7 @@ Reverb.prototype.process = function (interleavedSamples){
return outputSamples;
};

if (module && typeof module.exports !== 'undefined') {
if (typeof module !== 'undefined' && module && module.exports) {
module.exports = {
DSP: DSP,
DFT: DFT,
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dsp.js",
"version": "1.0.0",
"version": "1.0.1",
"description": "Digital Signal Processing for Javascript",
"main": "dsp.js",
"directories": {
Expand All @@ -22,4 +22,4 @@
"url": "https://github.com/corbanbrook/dsp.js/issues"
},
"homepage": "https://github.com/corbanbrook/dsp.js#readme"
}
}