fez-lisp 1.0.7 → 1.0.8

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/src/utils.js CHANGED
@@ -127,7 +127,7 @@ export const handleUnbalancedQuotes = (source) => {
127
127
  if (diff !== 0) throw new SyntaxError(`Quotes are unbalanced "`)
128
128
  return source
129
129
  }
130
-
130
+ export const removeMutation = (source) => source.replace(new RegExp(/!/g), 'ǃ')
131
131
  export const treeShake = (ast, libs) => {
132
132
  const deps = libs.reduce((a, x) => a.add(x.at(1)[VALUE]), new Set())
133
133
  const visited = new Set()
@@ -179,6 +179,7 @@ export const fez = (source, options = {}) => {
179
179
  handleUnbalancedParens(removeNoCode(source))
180
180
  )
181
181
  else code = removeNoCode(source)
182
+ if (options.immutable) code = removeMutation(code)
182
183
  const parsed = parse(code)
183
184
  const standard = options.std
184
185
  ? options.shake
@@ -190,7 +191,6 @@ export const fez = (source, options = {}) => {
190
191
  const js = Object.values(comp(deepClone(ast))).join('')
191
192
  return options.eval ? eval(js) : js
192
193
  }
193
-
194
194
  return run(ast, env)
195
195
  } catch (error) {
196
196
  const err = error.message
@@ -208,8 +208,8 @@ export const dotNamesToEmpty = (name) => name.replace(new RegExp(/\./g), '')
208
208
  export const colonNamesTo$ = (name) => name.replace(new RegExp(/\:/g), '$')
209
209
  export const commaToLodash = (name) => name.replace(new RegExp(/\,/g), '_')
210
210
  export const arrowToTo = (name) => name.replace(new RegExp(/->/g), '-to-')
211
- export const moduleNameToNothing = (name) =>
212
- name.replace(new RegExp(/::/g), '_')
211
+ export const moduleNameToLodashes = (name) =>
212
+ name.replace(new RegExp(/:/g), '_')
213
213
 
214
214
  export const questionMarkToLodash = (name) =>
215
215
  name.replace(new RegExp(/\?/g), 'Predicate')
@@ -242,7 +242,7 @@ export const lispToJavaScriptVariableName = (name) =>
242
242
  colonNamesTo$(
243
243
  exclamationMarkMarkToLodash(
244
244
  questionMarkToLodash(
245
- commaToLodash(moduleNameToNothing(earMuffsToLodashes(name)))
245
+ commaToLodash(moduleNameToLodashes(earMuffsToLodashes(name)))
246
246
  )
247
247
  )
248
248
  )