@jdeighan/coffee-utils 16.0.22 → 16.0.23

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,24 +1,19 @@
1
1
  {
2
2
  "name": "@jdeighan/coffee-utils",
3
3
  "type": "module",
4
- "version": "16.0.22",
4
+ "version": "16.0.23",
5
5
  "description": "A set of utility functions for CoffeeScript",
6
6
  "main": "coffee_utils.js",
7
7
  "exports": {
8
- ".": "./src/lib/browser.js",
8
+ ".": "./src/lib/fs.js",
9
9
  "./server": "./src/lib/server.js",
10
- "./browser": "./src/lib/browser.js",
11
10
  "./fs": "./src/lib/fs.js",
12
- "./log": "./src/lib/log.js",
11
+ "./fsa": "./src/lib/fsa.js",
13
12
  "./block": "./src/lib/block.js",
14
13
  "./indent": "./src/lib/indent.js",
15
14
  "./html": "./src/lib/html.js",
16
- "./stack": "./src/lib/stack.js",
17
- "./taml": "./src/lib/taml.js",
18
15
  "./section": "./src/lib/Section.js",
19
16
  "./sectionmap": "./src/lib/SectionMap.js",
20
- "./fsa": "./src/lib/fsa.js",
21
- "./giftset": "./src/lib/GiftSet.js",
22
17
  "./keyedset": "./src/lib/KeyedSet.js",
23
18
  "./package.json": "./package.json"
24
19
  },
@@ -53,7 +48,7 @@
53
48
  "svelte": "^4.1.1"
54
49
  },
55
50
  "devDependencies": {
56
- "@jdeighan/unit-tester": "^3.0.70",
51
+ "@jdeighan/unit-tester": "^3.0.71",
57
52
  "ava": "^6.0.1"
58
53
  }
59
54
  }
@@ -12,12 +12,3 @@ export exec = (cmd) =>
12
12
  windowsHide: true
13
13
  }
14
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
package/src/lib/server.js CHANGED
@@ -15,12 +15,3 @@ export var exec = (cmd) => {
15
15
  });
16
16
  return buffer.toString();
17
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 = (prompt) => {
23
- var answer;
24
- answer = getline.question("{prompt}? ");
25
- return answer;
26
- };
@@ -1,65 +0,0 @@
1
- # browser.coffee
2
-
3
- import {browser} from "$app/env"
4
-
5
- import {undef, defined, notdefined} from '@jdeighan/base-utils'
6
- import {assert, croak} from '@jdeighan/base-utils/exceptions'
7
-
8
- audio = undef # audio context - create only when needed, then keep
9
-
10
- # ---------------------------------------------------------------------------
11
- # beep - play a sound
12
-
13
- export beep = (volume=100, freq=520, duration=200) =>
14
-
15
- if audio == undef
16
- audio = new AudioContext()
17
- v = audio.createOscillator()
18
- u = audio.createGain()
19
- v.connect(u)
20
- v.frequency.value = freq
21
- v.type = "square"
22
- u.connect(audio.destination)
23
- u.gain.value = volume * 0.01
24
- v.start(audio.currentTime)
25
- v.stop(audio.currentTime + duration * 0.001)
26
- return
27
-
28
- # ---------------------------------------------------------------------------
29
-
30
- export localStorageAvailable = () ->
31
-
32
- if ! browser
33
- return false
34
- storage = window.localStorage
35
- if notdefined(storage)
36
- return false
37
- try
38
- x = '__storage_test__'
39
- storage.setItem x, x
40
- got = storage.getItem x
41
- storage.removeItem x
42
- return (got == x)
43
- catch e
44
- return false
45
-
46
- # ---------------------------------------------------------------------------
47
-
48
- export getLocalStore = (key, defValue={}) =>
49
-
50
- if ! localStorageAvailable()
51
- return undef
52
- if localStorage.hasOwnProperty(key)
53
- return JSON.parse(localStorage.getItem(key))
54
- else
55
- localStorage.setItem key, JSON.stringify(defValue)
56
- return defValue
57
-
58
- # ---------------------------------------------------------------------------
59
-
60
- export setLocalStore = (key, value) =>
61
-
62
- if ! localStorageAvailable()
63
- return
64
- localStorage.setItem key, JSON.stringify(value)
65
- return
@@ -1,82 +0,0 @@
1
- // Generated by CoffeeScript 2.7.0
2
- // browser.coffee
3
- var audio;
4
-
5
- import {
6
- browser
7
- } from "$app/env";
8
-
9
- import {
10
- undef,
11
- defined,
12
- notdefined
13
- } from '@jdeighan/base-utils';
14
-
15
- import {
16
- assert,
17
- croak
18
- } from '@jdeighan/base-utils/exceptions';
19
-
20
- audio = undef; // audio context - create only when needed, then keep
21
-
22
-
23
- // ---------------------------------------------------------------------------
24
- // beep - play a sound
25
- export var beep = (volume = 100, freq = 520, duration = 200) => {
26
- var u, v;
27
- if (audio === undef) {
28
- audio = new AudioContext();
29
- }
30
- v = audio.createOscillator();
31
- u = audio.createGain();
32
- v.connect(u);
33
- v.frequency.value = freq;
34
- v.type = "square";
35
- u.connect(audio.destination);
36
- u.gain.value = volume * 0.01;
37
- v.start(audio.currentTime);
38
- v.stop(audio.currentTime + duration * 0.001);
39
- };
40
-
41
- // ---------------------------------------------------------------------------
42
- export var localStorageAvailable = function() {
43
- var e, got, storage, x;
44
- if (!browser) {
45
- return false;
46
- }
47
- storage = window.localStorage;
48
- if (notdefined(storage)) {
49
- return false;
50
- }
51
- try {
52
- x = '__storage_test__';
53
- storage.setItem(x, x);
54
- got = storage.getItem(x);
55
- storage.removeItem(x);
56
- return got === x;
57
- } catch (error) {
58
- e = error;
59
- return false;
60
- }
61
- };
62
-
63
- // ---------------------------------------------------------------------------
64
- export var getLocalStore = (key, defValue = {}) => {
65
- if (!localStorageAvailable()) {
66
- return undef;
67
- }
68
- if (localStorage.hasOwnProperty(key)) {
69
- return JSON.parse(localStorage.getItem(key));
70
- } else {
71
- localStorage.setItem(key, JSON.stringify(defValue));
72
- return defValue;
73
- }
74
- };
75
-
76
- // ---------------------------------------------------------------------------
77
- export var setLocalStore = (key, value) => {
78
- if (!localStorageAvailable()) {
79
- return;
80
- }
81
- localStorage.setItem(key, JSON.stringify(value));
82
- };