Comparing version 0.1.1 to 0.1.2
# 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 |
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
85394
138
1