Socket
Book a DemoInstallSign in
Socket

sweet-syntax

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

sweet-syntax

Add syntactic sugar to any language!

unpublished
latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

npm install size

Add syntactic sugar to any language!

Install

Install sweet-syntax globally using npm:

npm install sweet-syntax -g

Usage

Once the installation is done, you can run the command inside your project's directory with your input and output file.

sweet-syntax input.myts output.ts

By default sweet-syntax will search the root of the current directory for a sweet-syntax.json file that contains your syntax configuration.

If the config file is located somewhere else, use the --config or -c argument with its path.

sweet-syntax input.myjs output.js -c configs/sweet-syntax.json

Finally, run this command to see a list of all available options:

sweet-syntax --help

As a loadable module

You can also use sweet-syntax as a module in your code.
First install it locally using npm:

npm install --save sweet-syntax

Then require and use it in your code:

const sweetSyntax = require('sweet-syntax');
const config = {
    objects: {
       HELLO: 'console.log'
    },
    keywords: {
        END: ';'
    }
}
const input = 'HELLO("Hello World")END';
const output = sweetSyntax.sweeten(config, input);

console.log(output);

// Output:
// console.log("Hello World");

Config

The config file should be named sweet-syntax.json and adopt the following structure:

{
    "keywords": {
        "LOOP": "for",
        "CHECK": "if",
        ...
    },
    "objects": {
        "LOG": "console.log",
        ... 
    },
    "operators": {
        "EQL": "===",
        "NQL": "!==",
        ...
    },
    "characters": {
        "{{": "",
        "}}": "",
        ...
    }
}

At least one object e.g. keywords must be provided by the config.

Examples

You can see examples of custom syntactic sugar under the examples folder:

License

Code released under the MIT License.

Enjoy ⭐️

Keywords

syntax

FAQs

Package last updated on 01 Nov 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts