-
-
Save victorb/62d7a1b7d41ce8cc2ad8fa4ac6c9f5e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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