UNPKG

5.12 kBMarkdownView Raw
1![](https://github.com/Luna-Klatzer/Kipper/raw/main/img/Kipper-Logo-with-head.png)
2
3# Kipper JavaScript Target - `@kipper/target-js`
4
5[![Version](https://img.shields.io/npm/v/@kipper/target-js?label=npm%20stable&color=%23cd2620&logo=npm)](https://npmjs.org/package/kipper)
6[![Dev Version](https://img.shields.io/github/v/tag/Luna-Klatzer/Kipper?include_prereleases&label=dev&logo=github&sort=semver)](https://github.com/Luna-Klatzer/Kipper/tags)
7[![codecov](https://codecov.io/gh/Luna-Klatzer/Kipper/branch/main/graph/badge.svg?token=S4RQT7X3YP)](https://codecov.io/gh/Luna-Klatzer/Kipper)
8[![Issues](https://img.shields.io/github/issues/Luna-Klatzer/Kipper)](https://github.com/Luna-Klatzer/Kipper/issues)
9[![License](https://img.shields.io/github/license/Luna-Klatzer/Kipper?color=cyan)](https://github.com/Luna-Klatzer/Kipper/blob/main/LICENSE)
10[![Install size](https://packagephobia.com/badge?p=@kipper/target-js)](https://packagephobia.com/result?p=@kipper/target-js)
11[![Publish size](https://badgen.net/packagephobia/publish/@kipper/target-js)](https://packagephobia.com/result?p=@kipper/target-js)
12
13The JavaScript target for the Kipper Compiler.
14
15Kipper is a JavaScript-like strongly and strictly typed language with Python flavour. It aims to provide
16straightforward, simple, secure and type-safe coding with better efficiency and developer satisfaction!
17
18It compiles to both JavaScript and TypeScript, and can be set up in your terminal, Node.js or ES6+ browser. 🦊
19
20_For more details, you can read more about this project on the [project repository](https://github.com/Luna-Klatzer/Kipper)
21and the [Kipper website](https://kipper-lang.org)._
22
23## Installation
24
25To install the whole Kipper package with its CLI, run the following command:
26
27```bash
28npm i @kipper/target-js
29```
30
31If you are using `pnpm` or `yarn`, use `pnpm i @kipper/target-js` or `yarn add @kipper/target-js`.
32
33## General Information
34
35- Website: https://kipper-lang.org
36- Docs: https://docs.kipper-lang.org
37- Playground: https://play.kipper-lang.org
38- Issue Tracker: https://issues.kipper-lang.org
39- Roadmap: [View Kipper Roadmap 🦊🚧](https://github.com/Luna-Klatzer/Kipper/discussions/139)
40- Changelog: [View CHANGELOG.md](https://github.com/Luna-Klatzer/Kipper/blob/main/CHANGELOG.md)
41
42## Usage
43
44Simply import the target and specify it in the `compilerOptions` field of `KipperCompiler.compile()`, for example:
45
46- JavaScript (CommonJS):
47
48 ```js
49 const fs = require("fs").promises;
50 const kipper = require("@kipper/core");
51 const kipperJS = require("@kipper/target-js");
52
53 const path = "INSERT_PATH";
54 fs.readFile(path, "utf8").then(async (fileContent) => {
55 const compiler = new kipper.KipperCompiler();
56
57 // Compile the code string or stream
58 let result = await compiler.compile(fileContent, { target: new kipperJS.TargetJS() });
59 let jsCode = result.write();
60
61 // Running the Kipper program
62 eval(jsCode);
63 });
64 ```
65
66- TypeScript (CommonJS):
67
68 ```ts
69 import { promises as fs } from "fs";
70 import { KipperCompiler } from "@kipper/core";
71 import { TargetJS } from "@kipper/target-js";
72
73 const path = "INSERT_PATH";
74 fs.readFile(path, "utf8" as BufferEncoding).then(async (fileContent: string) => {
75 const compiler = new KipperCompiler();
76
77 // Compile the code string or stream
78 let result = await compiler.compile(fileContent, { target: new TargetJS() });
79 let jsCode = result.write();
80
81 // Running the Kipper program
82 eval(jsCode);
83 });
84 ```
85
86If you are using `@kipper/cli` then this package is automatically installed and compiling to JavaScript can be done
87using the `--target=js` flag, for example:
88
89```bash
90kipper compile example-script.kip --target=js
91```
92
93## Kipper Docs
94
95Proper documentation for the Kipper language is available [here](https://kipper-lang.org/docs)!
96
97## Copyright and License
98
99![License](https://img.shields.io/github/license/Luna-Klatzer/Kipper?color=cyan)
100[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FLuna-Klatzer%2FKipper.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2FLuna-Klatzer%2FKipper?ref=badge_shield)
101
102Copyright (C) 2021-2023 Luna Klatzer
103
104This program is free software: you can redistribute it and/or modify it under
105the terms of the GNU General Public License as published by the Free Software
106Foundation, either version 3 of the License, or
107(at your option) any later version.
108
109This program is distributed in the hope that it will be useful, but WITHOUT ANY
110WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
111PARTICULAR PURPOSE. See the GNU General Public License for more details.
112
113You should have received a copy of the GNU General Public License along with
114this program. If not, see <https://www.gnu.org/licenses/>.
115
116See the [LICENSE](https://raw.githubusercontent.com/Luna-Klatzer/Kipper/main/LICENSE)
117for information on terms & conditions for usage.
118
119### FOSSA License Report
120
121[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FLuna-Klatzer%2FKipper.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2FLuna-Klatzer%2FKipper?ref=badge_large)