@jdeighan/coffee-utils 4.1.31 → 4.1.32

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jdeighan/coffee-utils",
3
3
  "type": "module",
4
- "version": "4.1.31",
4
+ "version": "4.1.32",
5
5
  "description": "A set of utility functions for CoffeeScript",
6
6
  "main": "coffee_utils.js",
7
7
  "exports": {
@@ -1,6 +1,7 @@
1
1
  # DataStores.coffee
2
2
 
3
3
  import pathlib from 'path'
4
+ import yaml from 'js-yaml'
4
5
  import {writable, readable, get} from 'svelte/store'
5
6
 
6
7
  import {
@@ -10,7 +11,6 @@ import {log} from '@jdeighan/coffee-utils/log'
10
11
  import {
11
12
  withExt, slurp, barf, newerDestFileExists,
12
13
  } from '@jdeighan/coffee-utils/fs'
13
- import {isTAML, taml} from '@jdeighan/string-input/taml'
14
14
 
15
15
  # ---------------------------------------------------------------------------
16
16
 
@@ -128,6 +128,14 @@ export class TAMLDataStore extends WritableDataStore
128
128
  # UTILITIES
129
129
  # ---------------------------------------------------------------------------
130
130
 
131
+ export taml = (text) ->
132
+
133
+ if ! text?
134
+ return undef
135
+ return yaml.load(untabify(text, 1), {skipInvalid: true})
136
+
137
+ # ---------------------------------------------------------------------------
138
+
131
139
  export brewTamlStr = (code, stub) ->
132
140
 
133
141
  return """
package/src/DataStores.js CHANGED
@@ -2,6 +2,8 @@
2
2
  // DataStores.coffee
3
3
  import pathlib from 'path';
4
4
 
5
+ import yaml from 'js-yaml';
6
+
5
7
  import {
6
8
  writable,
7
9
  readable,
@@ -28,11 +30,6 @@ import {
28
30
  newerDestFileExists
29
31
  } from '@jdeighan/coffee-utils/fs';
30
32
 
31
- import {
32
- isTAML,
33
- taml
34
- } from '@jdeighan/string-input/taml';
35
-
36
33
  // ---------------------------------------------------------------------------
37
34
  export var WritableDataStore = class WritableDataStore {
38
35
  constructor(value = undef) {
@@ -170,6 +167,16 @@ export var TAMLDataStore = class TAMLDataStore extends WritableDataStore {
170
167
 
171
168
  // ---------------------------------------------------------------------------
172
169
  // UTILITIES
170
+ // ---------------------------------------------------------------------------
171
+ export var taml = function(text) {
172
+ if (text == null) {
173
+ return undef;
174
+ }
175
+ return yaml.load(untabify(text, 1), {
176
+ skipInvalid: true
177
+ });
178
+ };
179
+
173
180
  // ---------------------------------------------------------------------------
174
181
  export var brewTamlStr = function(code, stub) {
175
182
  return `import {TAMLDataStore} from '@jdeighan/starbucks/stores';