@jdeighan/coffee-utils 4.1.23 → 4.1.24
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
{
|
2
2
|
"name": "@jdeighan/coffee-utils",
|
3
3
|
"type": "module",
|
4
|
-
"version": "4.1.
|
4
|
+
"version": "4.1.24",
|
5
5
|
"description": "A set of utility functions for CoffeeScript",
|
6
6
|
"main": "coffee_utils.js",
|
7
7
|
"exports": {
|
8
8
|
".": "./src/coffee_utils.js",
|
9
|
-
"./
|
9
|
+
"./server": "./src/server_utils.js",
|
10
|
+
"./browser": "./src/browser_utils.js",
|
10
11
|
"./fs": "./src/fs_utils.js",
|
11
12
|
"./log": "./src/log_utils.js",
|
12
13
|
"./block": "./src/block_utils.js",
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# browser_utils.coffee
|
2
|
+
|
3
|
+
# ---------------------------------------------------------------------------
|
4
|
+
# beep - play a sound
|
5
|
+
|
6
|
+
export beep = (volume=100, freq=520, duration=200) ->
|
7
|
+
|
8
|
+
v = @audio.createOscillator()
|
9
|
+
u = @audio.createGain()
|
10
|
+
v.connect(u)
|
11
|
+
v.frequency.value = freq
|
12
|
+
v.type = "square"
|
13
|
+
u.connect(@audio.destination)
|
14
|
+
u.gain.value = volume * 0.01
|
15
|
+
v.start(@audio.currentTime)
|
16
|
+
v.stop(@audio.currentTime + duration * 0.001)
|
17
|
+
return
|
@@ -0,0 +1,17 @@
|
|
1
|
+
// Generated by CoffeeScript 2.6.1
|
2
|
+
// browser_utils.coffee
|
3
|
+
|
4
|
+
// ---------------------------------------------------------------------------
|
5
|
+
// beep - play a sound
|
6
|
+
export var beep = function(volume = 100, freq = 520, duration = 200) {
|
7
|
+
var u, v;
|
8
|
+
v = this.audio.createOscillator();
|
9
|
+
u = this.audio.createGain();
|
10
|
+
v.connect(u);
|
11
|
+
v.frequency.value = freq;
|
12
|
+
v.type = "square";
|
13
|
+
u.connect(this.audio.destination);
|
14
|
+
u.gain.value = volume * 0.01;
|
15
|
+
v.start(this.audio.currentTime);
|
16
|
+
v.stop(this.audio.currentTime + duration * 0.001);
|
17
|
+
};
|