@jdeighan/coffee-utils 4.1.20 → 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,11 +1,13 @@
1
1
  {
2
2
  "name": "@jdeighan/coffee-utils",
3
3
  "type": "module",
4
- "version": "4.1.20",
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
+ "./server": "./src/server_utils.js",
10
+ "./browser": "./src/browser_utils.js",
9
11
  "./fs": "./src/fs_utils.js",
10
12
  "./log": "./src/log_utils.js",
11
13
  "./block": "./src/block_utils.js",
@@ -24,8 +26,7 @@
24
26
  },
25
27
  "scripts": {
26
28
  "build": "cls && rm -f ./src/*.js && coffee -c ./src",
27
- "old_pretest": "npm run build && rm -f ./test/*.js && rm -f ./test/*.coffee && cielo -fq ./test",
28
- "pretest": "cls && coffee -c .",
29
+ "pretest": "cls && cielo -qfc ./test && coffee -c ./test",
29
30
  "test": "ava ./test/*.test.js",
30
31
  "prefinaltest": "npm run pretest",
31
32
  "finaltest": "cross-env FINALTEST=yes ava ./test/*.test.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
+ };
@@ -1,24 +1,11 @@
1
1
  # coffee_utils.coffee
2
2
 
3
- import getline from 'readline-sync'
4
- import {execSync} from 'child_process'
5
-
6
3
  import {log} from '@jdeighan/coffee-utils/log'
7
4
 
8
5
  export sep_dash = '-'.repeat(42)
9
6
  export sep_eq = '='.repeat(42)
10
7
  `export const undef = undefined`
11
8
 
12
- # ---------------------------------------------------------------------------
13
- # exec - run external commands
14
-
15
- export exec = (cmd) ->
16
-
17
- buffer = execSync cmd, {
18
- windowsHide: true
19
- }
20
- return buffer.toString()
21
-
22
9
  # ---------------------------------------------------------------------------
23
10
  # pass - do nothing
24
11
 
@@ -261,15 +248,6 @@ export say = (x) ->
261
248
  console.log x
262
249
  return
263
250
 
264
- # ---------------------------------------------------------------------------
265
- # ask - ask a question
266
- # later, on a web page, prompt the user for answer to question
267
-
268
- export ask = (prompt) ->
269
-
270
- answer = getline.question("{prompt}? ")
271
- return answer
272
-
273
251
  # ---------------------------------------------------------------------------
274
252
 
275
253
  export titleLine = (title, char='=', padding=2, linelen=42) ->
@@ -2,12 +2,6 @@
2
2
  // coffee_utils.coffee
3
3
  var commentRegExp;
4
4
 
5
- import getline from 'readline-sync';
6
-
7
- import {
8
- execSync
9
- } from 'child_process';
10
-
11
5
  import {
12
6
  log
13
7
  } from '@jdeighan/coffee-utils/log';
@@ -18,16 +12,6 @@ export var sep_eq = '='.repeat(42);
18
12
 
19
13
  export const undef = undefined;
20
14
 
21
- // ---------------------------------------------------------------------------
22
- // exec - run external commands
23
- export var exec = function(cmd) {
24
- var buffer;
25
- buffer = execSync(cmd, {
26
- windowsHide: true
27
- });
28
- return buffer.toString();
29
- };
30
-
31
15
  // ---------------------------------------------------------------------------
32
16
  // pass - do nothing
33
17
  export var pass = function() {};
@@ -265,15 +249,6 @@ export var say = function(x) {
265
249
  }
266
250
  };
267
251
 
268
- // ---------------------------------------------------------------------------
269
- // ask - ask a question
270
- // later, on a web page, prompt the user for answer to question
271
- export var ask = function(prompt) {
272
- var answer;
273
- answer = getline.question("{prompt}? ");
274
- return answer;
275
- };
276
-
277
252
  // ---------------------------------------------------------------------------
278
253
  export var titleLine = function(title, char = '=', padding = 2, linelen = 42) {
279
254
  var nLeft, nRight, strLeft, strMiddle, strRight, titleLen;
@@ -0,0 +1,23 @@
1
+ # server_utils.coffee
2
+
3
+ import getline from 'readline-sync'
4
+ import {execSync} from 'child_process'
5
+
6
+ # ---------------------------------------------------------------------------
7
+ # exec - run external commands
8
+
9
+ export exec = (cmd) ->
10
+
11
+ buffer = execSync cmd, {
12
+ windowsHide: true
13
+ }
14
+ return buffer.toString()
15
+
16
+ # ---------------------------------------------------------------------------
17
+ # ask - ask a question
18
+ # later, on a web page, prompt the user for answer to question
19
+
20
+ export ask = (prompt) ->
21
+
22
+ answer = getline.question("{prompt}? ")
23
+ return answer
@@ -0,0 +1,26 @@
1
+ // Generated by CoffeeScript 2.6.1
2
+ // server_utils.coffee
3
+ import getline from 'readline-sync';
4
+
5
+ import {
6
+ execSync
7
+ } from 'child_process';
8
+
9
+ // ---------------------------------------------------------------------------
10
+ // exec - run external commands
11
+ export var exec = function(cmd) {
12
+ var buffer;
13
+ buffer = execSync(cmd, {
14
+ windowsHide: true
15
+ });
16
+ return buffer.toString();
17
+ };
18
+
19
+ // ---------------------------------------------------------------------------
20
+ // ask - ask a question
21
+ // later, on a web page, prompt the user for answer to question
22
+ export var ask = function(prompt) {
23
+ var answer;
24
+ answer = getline.question("{prompt}? ");
25
+ return answer;
26
+ };