0.3.1 • Published 5 years ago

@hsk81/duke.js v0.3.1

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

Duke.js: a minimal JavaScript interpreter

Duke.js is a minimal JavaScript interpreter, which has been build with Duktape an embeddable and portable Javascript engine with a compact footprint. The duke interpreter consumes JavaScript code from the standard input and then evaluates it.

Prerequisites

Name            : cmake
Version         : 3.14.5-1
Description     : A cross-platform open-source make system
URL             : https://www.cmake.org/

Installation

npm install @hsk81/duke.js -g

Development

Cleaning

npm run clean

Building

npm run build

Testing

npm run test

Usage

Doing Arithmetic

echo "1/0" | duke
⪡ Infinity

Using Functions

echo "function id(a) { return a; }; id(1)" | duke
⪡ 1

Console Logging

echo "console.log('message')" | duke
⪢ message
⪡ undefined
echo "console.error('message')" | duke
⫸ Error: message
⪡ undefined

Throwing Errors

echo "throw new Error('message')" | duke
⫷ Error: message

Running Scripts

cat ./tst/dracula.js | duke ## or:
duke < ./tst/dracula.js
⪢ Duke: "dracula"
⪡ undefined

Copyright

© 2019 Hasan Karahan