playjs-core
v0.7.2
Published
Add a JavaScript Playground on your project.
Maintainers
Readme
Add a JavaScript Playground on your project.
Installation
npm install react react-dom playjs-coreyarn add react react-dom playjs-corepnpm install react react-dom playjs-coreBasic usage
import { PlayJS } from 'playjs-core';
<PlayJS />TypeScript support
<PlayJS language="typescript" />Preload code
<PlayJS code="console.log('Hello, world!')" />Themes
<PlayJS theme="dark" />
<PlayJS theme="light" />Testing Helpers
PlayJS includes a minimal testing API available inside the editor:
expect(actual).eq(expected)expect(actual).neq(expected)expect(actual).truthy()expect(actual).falsy()cases(fn, [[input, expected], ...])
Examples
expect(2 + 2).eq(4)
// ➜ '✓' 4 'eq' 4
expect(2 + 2).eq(5)
// ➜ '✗' 4 'eq' 5
expect(0).falsy()
// ➜ '✓' 0 'falsy' false
function double(n){ return n * 2 }
cases(double, [[1,2],[3,6],[5,10]])
// ➜ '✓' 2 'eq' 2 ┊ '✓' 6 'eq' 6 ┊ '✓' 10 'eq' 10These helpers log concise results to the Console pane without requiring any imports.
Contributing
If you think PlayJS is a cool project and you would like to do your bit, check out How to Contribute for more information.
