1.0.6 • Published 5 years ago

transformscript v1.0.6

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

TransformScript (Beta)

TransformScript is a tiny programming language, which allows visitors of websites to easily transform data on client side.

Installation

Use npm (node package manager) to install TransformScript.

npm i transformscript

Usage

TransformScript is interpreted by JavaScript. Here's an basic example which takes a List <Number> as an argument and returns the the list with each element multiplied with itself.

import TransformScript from 'transformscript'

const code = `
    use console as Console
    take list as List <Number>

    for index in 0..<list.length {
        let number = list.item(at: index)
        let result = number * number

        list.set(value: result, at: index)
    }

    console.print(message: list)
    exit list
`

new TransformScript(code).run([1, 2, 3, 4, 5, 6])

The output would be:

[1, 4, 9, 16, 25, 36]

Quick Overview

What's the use-case of TransformScript?

TransformScript is first of all a educational project for myself. Nethertheless it's intentional use case is the transformation of data at runtime. The support of Link-Ins makes it easy for TransformScript to interact with the hosting webpage without the need to provide an API for modification of the doom.

How to interact with JavaScrip (TypeScript)

The interaction between TransformScript and JavaScript is based mainly on Link-Ins. Link-Ins are subclasses of the abstract class LinkedIn. They can use all basic types as properties, function arguments or function return types. Inside these classes any operation can be performed. TransformScript accepts an instance of any subclass of LinkedIn. They are passed using the use keyword (the take keyword is equivalent to use but not good style). Of course a Link-In has to be provided to the script before you can use it inside the script. Call <instance of TransformScript>.provide(<instance of LinkedIn>) before calling <instance of TransformScript>.run()

To pass basic values the use of runtime arguments is recommended. They are passed to the run method of TransformScript. They must be of type boolean, string, number or Array<number | boolean | string>. Inside the script they are imported using the take keyword.

Bugs

Did you find any bugs? Please send an email to "henrik" + "@" + "thoroee.com". The email should describe at least how to reproduce the error or unexpected behaviour.

Roadmap

  1. Add support for power operator (^)
  2. Add support for comments (// or #?)
  3. Clean up or rewrite the lexer and parser.
    • Both classes were quickly written, which is why they look ugly now.
1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago