# puzzlelang

> An abstract, extendable programing language on top of JavaScript

Latest version **0.0.977** (published 2024-10-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install puzzlelang
pnpm add puzzlelang
yarn add puzzlelang
bun add puzzlelang
```

Provides the command `puzzle`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.977 |
| Published | 2024-10-08 |
| First published | 2020-09-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 883.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Marco Boelling |
| Maintainers | marcoboelling |

## Links

- npm: https://www.npmjs.com/package/puzzlelang
- Repository: https://github.com/puzzlelang/puzzle
- Homepage: https://puzzlelang.org
- Issues: https://github.com/puzzlelang/puzzle/issues
- npm.io page: https://npm.io/package/puzzlelang

## Dependencies (7)

- [npmview](https://npm.io/package/npmview.md) 0.0.4
- [tinyify](https://npm.io/package/tinyify.md) ^2.5.2
- [inquirer](https://npm.io/package/inquirer.md) ^7.3.0
- [commander](https://npm.io/package/commander.md) ^5.1.0
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.7
- [node-fetch-npm](https://npm.io/package/node-fetch-npm.md) ^2.0.4
- [node-localstorage](https://npm.io/package/node-localstorage.md) ^2.1.6

## Recent versions

- 0.0.977 (latest) — 2024-10-08
- 0.0.71 (beta) — 2021-10-16
- 0.0.976 — 2024-06-17
- 0.0.975 — 2024-06-17
- 0.0.974 — 2024-06-17
- 0.0.973 — 2024-04-12
- 0.0.972 — 2023-12-07
- 0.0.971 — 2023-11-16
- 0.0.970 — 2023-07-28
- 0.0.969 — 2023-05-26
- 0.0.968 — 2023-05-26
- 0.0.967 — 2023-05-03
- 0.0.966 — 2023-05-01
- 0.0.965 — 2023-04-04
- 0.0.964 — 2023-03-31
- … 66 more at https://npm.io/package/puzzlelang/versions

## README

![puzzle](https://github.com/puzzlelang/puzzlelang.github.io/blob/master/assets/puzzle.png?raw=true "Puzzle logo")

<div class="cover-main"><!-- _coverpage.md -->
<h1 class="header" style="padding: 0px !important;margin-left:0px;">An <span class="highlight-primary">abstract</span>, fluent programming language on top of JavaScript</h1>

> Comes with ready-to-use features for any purpose

***Important:*** The puzzle project is in early stage and under development. It's not yet production ready. If you'd like to contribute to the code or the module ecosystem, feel free to open a PR.

# Example

```puzzle
every(1000).print('hello world')
```

# Get started

PUZZLE runs in any JavaScript environment, including Node and Browsers.

> Node

```shell
$ npm i puzzlelang --global
```
```javascript
const puzzle = require('puzzlelang');

print('hello')
```

> Browsers

```html
<script src="https://cdn.jsdelivr.net/npm/puzzlelang@latest/puzzle.browser.js">
```
```html
<script type="text/javascript">
  print("hello from the browser!");
</script>
```

# Language Basics

## Print

```javascript
print('hello')
```

## Variables

Variables can be defined either the JavaScript way or using puzzle syntax

```javascript
// with JavaScript
var name = 'Peter';

// with Puzzle
set('name', 'Peter')
print(name)
```

## Persistent Variables

Persistend variables are stored locally

```javascript
set('name', 'Peter').local()
```

## Functions

Like variables, functions can also be defined either the JavaScript way or using puzzle syntax

```javascript
set('sayHello', (name) => {
  print('hello ' + name)
})

// With JavaScript
var sayHello = () => {
  print('hello')
}
```


## Scheduled Functions

Functions can be scheduled

```javascript
// Repeat every X milliseconds
every(2000).run(sayHello)

// Repeat X times
repeat(10).run(sayHello)

// Run after X milliseconds
after(10000).run(sayHello)
```

## Loops

Loops can iteragte over data (arrays)

```javascript
var array = [1,2,3]

loop.over(data).do(it => {
  print(it)
})
```


## Math

```javascript
// min and max
min([1,4,6,7]).as('result')
max([4,7,8,2]).as('result')
```

---
_Source: https://npm.io/package/puzzlelang · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
