stencila/libcore
: core function library
This the Stencila Core Library, a library of functions that are built in to Stencila's Mini language. It is to Stencila what Excel functions are to Excel, the Python Standard Library is to Python, the R Base Package is to R, etc, etc.
Want to see a list of functions currently implemented in Stencila? Check out our list of functions here.
Want to contribute a function to Libcore? More on contributing to Libcore here.
Stencila functions can be implemented, and used, in a variety of languages. Mini is intentionally simple. Instead of trying to be a complete programming language, it focuses on being a "glue" between other languages. This allows functions to be implemented using the best language for the job. And when a function is implemented in multiple languages, this approach allows for the optimization of function calls based on implementation speed and data location. Learn more about Mini here.
A folder for cordinating design and implementations of functions across langages.
Javascript
Create the Javascript function in the relevant ./src/*.js
file with the same name as the function e.g. function sum(x)...
for sum.fun.xml
.
If your implementation overloads parameter types then you will need to handle that in the implementation.
Currently, the following are available in the global environment:
Test
Run all tests in Node.js:
npm test
Run all tests in the browser:
npm run test-browser
then open test/index.html
.
To watch source code and run tests on changes use the -w
flag to make.js
node make test -w
node make test:browser -w
Try
You can try out functions in the browser developer console by building the distribution:
npm run build
then open index.html
.