Skip to content

Instantly share code, notes, and snippets.

@victorb

victorb/test.js Secret

Created August 12, 2021 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save victorb/62d7a1b7d41ce8cc2ad8fa4ac6c9f5e1 to your computer and use it in GitHub Desktop.
Save victorb/62d7a1b7d41ce8cc2ad8fa4ac6c9f5e1 to your computer and use it in GitHub Desktop.
const sci = require('./sci-lib.js')
const cljs = require('./clojure.core.prod.js')
const getMethods = (obj) => {
let properties = new Set()
let currentObj = obj
do {
Object.getOwnPropertyNames(currentObj).map(item => properties.add(item))
} while ((currentObj = Object.getPrototypeOf(currentObj)))
return [...properties.keys()].filter(item => typeof obj[item] === 'function')
}
const k_classes = cljs.keyword("classes")
const k_deny = cljs.keyword("deny")
const ctx = sci.init(
cljs.jsToClj(
{[k_deny]: [cljs.str],
[k_classes]: {[k_deny]: [cljs.str]}}
))
// console.log(sci)
// console.log(getMethods(sci))
console.log(sci.evalString('(str "hello world")'), {})
console.log(sci.evalStringWithCtx(ctx, '(str "I should not be visible!")'))
// console.log(sci.evalStringWithCtx(ctx, '(+ 1 1)'))
// console.log(sci.evalStringWithCtx(ctx, '(def my-number 2)'))
// console.log(sci.evalStringWithCtx(ctx, '(* my-number 4)'))
// console.log(sci.evalStringWithCtx(ctx, '(str "I should not be visible!")'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment