Socket
Socket
Sign inDemoInstall

code-red

Package Overview
Dependencies
6
Maintainers
2
Versions
53
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.1 to 0.1.2

6

CHANGELOG.md
# code-red changelog
## 0.1.2
* Don't crash when using an arrow function as a statement ([#38](https://github.com/Rich-Harris/code-red/issues/38))
## 0.1.1

@@ -140,2 +144,2 @@

* First experimental release
* First experimental release

4

dist/code-red.js

@@ -339,5 +339,5 @@ (function (global, factory) {

ExpressionStatement(node, state) {
const precedence = EXPRESSIONS_PRECEDENCE[node.expression.type];
if (
precedence === 3 && (node.expression ).left.type === 'ObjectPattern'
node.expression.type === 'AssignmentExpression' &&
node.expression.left.type === 'ObjectPattern'
) {

@@ -344,0 +344,0 @@ // is an AssignmentExpression to an ObjectPattern

{
"name": "code-red",
"description": "code-red",
"version": "0.1.1",
"version": "0.1.2",
"repository": "Rich-Harris/code-red",

@@ -6,0 +6,0 @@ "main": "dist/code-red.js",

# code-red
Experimental toolkit for writing x-to-JavaScript compilers. May end up getting used in [Svelte](https://svelte.dev), if it works.
Experimental toolkit for writing x-to-JavaScript compilers. It is used in [Svelte](https://svelte.dev).

@@ -73,3 +73,49 @@

## Prefixes
### `@`-prefixed names (replaceable globals)
So that you can use globals in your code. In Svelte, we use this to insert utility functions.
```js
// input
import { x } from 'code-red';
x`@foo(bar)`
// output
FOO(bar)
```
### `#`-prefixed names (automatically deconflicted names)
So that you can insert variables in your code without worrying if they clash with existing variable names.
`bar` used in user code and in inserted code gets a `$1` suffix:
```js
// input
import { x } from 'code-red';
x`
function foo(#bar) {
return #bar * bar;
}`;
// output
function foo(bar$1) {
return bar$1 * bar;
}
```
Without conflicts, no `$1` suffix:
```js
// input
import { b } from 'code-red';
b`const foo = #bar => #bar * 2`;
// output
const foo = bar => bar * 2;
```
## Optimiser

@@ -92,2 +138,2 @@

[MIT](LICENSE)
[MIT](LICENSE)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc