@jdeighan/coffee-utils 4.1.23 → 4.1.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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.27",
|
|
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",
|
|
@@ -25,7 +26,7 @@
|
|
|
25
26
|
},
|
|
26
27
|
"scripts": {
|
|
27
28
|
"build": "cls && rm -f ./src/*.js && coffee -c ./src",
|
|
28
|
-
"pretest": "cls && cielo -qfc ./test && coffee -c
|
|
29
|
+
"pretest": "cls && cielo -qfc ./test && coffee -c .",
|
|
29
30
|
"test": "ava ./test/*.test.js",
|
|
30
31
|
"prefinaltest": "npm run pretest",
|
|
31
32
|
"finaltest": "cross-env FINALTEST=yes ava ./test/*.test.js"
|
|
@@ -47,6 +48,7 @@
|
|
|
47
48
|
"ava": "^3.15.0",
|
|
48
49
|
"cross-env": "^7.0.3",
|
|
49
50
|
"js-yaml": "^4.1.0",
|
|
50
|
-
"readline-sync": "^1.4.10"
|
|
51
|
+
"readline-sync": "^1.4.10",
|
|
52
|
+
"svelte": "^3.46.3"
|
|
51
53
|
}
|
|
52
54
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# browser_utils.coffee
|
|
2
|
+
|
|
3
|
+
import {undef} from '@jdeighan/coffee-utils'
|
|
4
|
+
|
|
5
|
+
audio = undef # audio context - create only when needed, then keep
|
|
6
|
+
|
|
7
|
+
# ---------------------------------------------------------------------------
|
|
8
|
+
# beep - play a sound
|
|
9
|
+
|
|
10
|
+
export beep = (volume=100, freq=520, duration=200) ->
|
|
11
|
+
|
|
12
|
+
if audio == undef
|
|
13
|
+
audio = new AudioContext()
|
|
14
|
+
v = audio.createOscillator()
|
|
15
|
+
u = audio.createGain()
|
|
16
|
+
v.connect(u)
|
|
17
|
+
v.frequency.value = freq
|
|
18
|
+
v.type = "square"
|
|
19
|
+
u.connect(audio.destination)
|
|
20
|
+
u.gain.value = volume * 0.01
|
|
21
|
+
v.start(audio.currentTime)
|
|
22
|
+
v.stop(audio.currentTime + duration * 0.001)
|
|
23
|
+
return
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Generated by CoffeeScript 2.6.1
|
|
2
|
+
// browser_utils.coffee
|
|
3
|
+
var audio;
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
undef
|
|
7
|
+
} from '@jdeighan/coffee-utils';
|
|
8
|
+
|
|
9
|
+
audio = undef; // audio context - create only when needed, then keep
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
// beep - play a sound
|
|
14
|
+
export var beep = function(volume = 100, freq = 520, duration = 200) {
|
|
15
|
+
var u, v;
|
|
16
|
+
if (audio === undef) {
|
|
17
|
+
audio = new AudioContext();
|
|
18
|
+
}
|
|
19
|
+
v = audio.createOscillator();
|
|
20
|
+
u = audio.createGain();
|
|
21
|
+
v.connect(u);
|
|
22
|
+
v.frequency.value = freq;
|
|
23
|
+
v.type = "square";
|
|
24
|
+
u.connect(audio.destination);
|
|
25
|
+
u.gain.value = volume * 0.01;
|
|
26
|
+
v.start(audio.currentTime);
|
|
27
|
+
v.stop(audio.currentTime + duration * 0.001);
|
|
28
|
+
};
|
package/src/svelte_utils.coffee
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# svelte_utils.coffee
|
|
2
2
|
|
|
3
|
+
import {onDestroy} from 'svelte'
|
|
4
|
+
|
|
3
5
|
# ---------------------------------------------------------------------------
|
|
4
6
|
# svelteSourceCodeEsc - to display source code for a *.starbucks page
|
|
5
7
|
|
|
@@ -24,3 +26,9 @@ export svelteHtmlEsc = (str) ->
|
|
|
24
26
|
|
|
25
27
|
# ---------------------------------------------------------------------------
|
|
26
28
|
|
|
29
|
+
export onInterval = (func, secs) ->
|
|
30
|
+
|
|
31
|
+
interval = setInterval(func, Math.floor(1000 * secs))
|
|
32
|
+
|
|
33
|
+
onDestroy () ->
|
|
34
|
+
clearInterval interval
|
package/src/svelte_utils.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
// Generated by CoffeeScript 2.6.1
|
|
2
|
-
// svelte_utils.coffee
|
|
2
|
+
// svelte_utils.coffee
|
|
3
|
+
import {
|
|
4
|
+
onDestroy
|
|
5
|
+
} from 'svelte';
|
|
3
6
|
|
|
4
7
|
// ---------------------------------------------------------------------------
|
|
5
8
|
// svelteSourceCodeEsc - to display source code for a *.starbucks page
|
|
@@ -14,3 +17,10 @@ export var svelteHtmlEsc = function(str) {
|
|
|
14
17
|
};
|
|
15
18
|
|
|
16
19
|
// ---------------------------------------------------------------------------
|
|
20
|
+
export var onInterval = function(func, secs) {
|
|
21
|
+
var interval;
|
|
22
|
+
interval = setInterval(func, Math.floor(1000 * secs));
|
|
23
|
+
return onDestroy(function() {
|
|
24
|
+
return clearInterval(interval);
|
|
25
|
+
});
|
|
26
|
+
};
|