{"id":14155542,"url":"https://github.com/coderaiser/goldstein","last_synced_at":"2026-02-15T01:06:30.925Z","repository":{"id":37451996,"uuid":"505836818","full_name":"coderaiser/goldstein","owner":"coderaiser","description":"JavaScript with no limits 🤫","archived":false,"fork":false,"pushed_at":"2026-02-11T22:16:22.000Z","size":516,"stargazers_count":13,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2026-02-12T06:26:44.968Z","etag":null,"topics":["acorn","javascript","nodejs","parser","putout"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coderaiser.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"coderaiser","patreon":"coderaiser","open_collective":"cloudcmd","ko_fi":"coderaiser"}},"created_at":"2022-06-21T12:37:40.000Z","updated_at":"2026-02-11T22:16:26.000Z","dependencies_parsed_at":"2024-04-28T16:37:34.114Z","dependency_job_id":"941db742-625b-4d3d-b247-06e936e4bed9","html_url":"https://github.com/coderaiser/goldstein","commit_stats":{"total_commits":232,"total_committers":4,"mean_commits":58.0,"dds":"0.10344827586206895","last_synced_commit":"5cca0e0624e8c1cec08dd7f85348ef8d32729bb4"},"previous_names":[],"tags_count":105,"template":false,"template_full_name":null,"purl":"pkg:github/coderaiser/goldstein","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderaiser%2Fgoldstein","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderaiser%2Fgoldstein/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderaiser%2Fgoldstein/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderaiser%2Fgoldstein/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coderaiser","download_url":"https://codeload.github.com/coderaiser/goldstein/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderaiser%2Fgoldstein/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29460143,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T22:42:09.113Z","status":"ssl_error","status_checked_at":"2026-02-14T22:42:05.053Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["acorn","javascript","nodejs","parser","putout"],"created_at":"2024-08-17T08:03:48.831Z","updated_at":"2026-02-15T01:06:30.918Z","avatar_url":"https://github.com/coderaiser.png","language":"JavaScript","funding_links":["https://github.com/sponsors/coderaiser","https://patreon.com/coderaiser","https://opencollective.com/cloudcmd","https://ko-fi.com/coderaiser"],"categories":["nodejs"],"sub_categories":[],"readme":"# 🤫Goldstein [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] [![Coverage Status][CoverageIMGURL]][CoverageURL]\n\n[NPMURL]: https://npmjs.org/package/goldstein \"npm\"\n[NPMIMGURL]: https://img.shields.io/npm/v/goldstein.svg?style=flat\n[BuildStatusURL]: https://github.com/coderaiser/goldstein/actions?query=workflow%3A%22Node+CI%22 \"Build Status\"\n[BuildStatusIMGURL]: https://github.com/coderaiser/goldstein/workflows/Node%20CI/badge.svg\n[LicenseURL]: https://tldrlegal.com/license/mit-license \"MIT License\"\n[LicenseIMGURL]: https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat\n[CoverageURL]: https://coveralls.io/github/coderaiser/goldstein?branch=master\n[CoverageIMGURL]: https://coveralls.io/repos/coderaiser/goldstein/badge.svg?branch=master\u0026service=github\n\n![image](https://user-images.githubusercontent.com/1573141/175353192-9867d3ba-beaf-46d5-adbc-e2eb736bfef1.png)\n\n\u003e *\"You haven't a real appreciation of Newspeak, Winston,\" he said almost sadly. \"Even when you write it you're still thinking in Oldspeak. I've read some of those pieces that you write in The Times occasionally. They're good enough, but they're translations. In your heart you'd prefer to stick to Oldspeak, with all its vagueness and its useless shades of meaning. You don't grasp the beauty of the destruction of words. Do you know that Newspeak is the only language in the world whose vocabulary gets smaller every year?\"*\n\u003e\n\u003e *(c) “1984”, George Orwell*\n\nJavaScript with no limits 🤫 with built-in JSX and TypeScript.\nLanguage ruled by the users, [create an issue](https://github.com/coderaiser/goldstein/issues/new/choose) with ideas of a new language construction and what is look like in JavaScript, and most likely we implement it :).\n\n## Install\n\n```\nnpm i goldstein esbuild -g\n```\n\n## CLI\n\n```\n$ cat \u003e 1.gs\nexport fn hello() {\n    return 'world';\n}\n\n$ gs 1.gs\n$ cat 1.js\nfunction hello() {\n    return \"world\";\n}\nexport {\n    hello,\n};\n```\n\nLet's do a bit more!\n\n```gs\nconst a = () =\u003e throw 'hello';\n\nif a \u003e 2 {\n    log('hello');\n}\n```\n\nWill give us:\n\n```js\nconst a = () =\u003e {\n    throw 'hello';\n};\n\nif (a \u003e 2) {\n    log('hello');\n}\n```\n\n## API\n\n### `compile(source)`\n\nWhen you need to compile **Goldstein** to **JavaScript** use:\n\n```js\nimport {compile} from 'goldstein';\n\ncompile(`\n    fn hello() {\n        guard text !== \"world\" else {\n            return \"\"\n        }\n        \n        return \"Hello \" + text\n    }\n`);\n\n// returns\n`\nfunction hello() {\n    if (!(text !== 'world')) {\n        return '';\n    }\n    \n    return 'Hello ' + text;\n}\n`;\n```\n\nBy default, all keywords mentioned in the next section used, but you can limit the list setting with `keywords` option.\nYou can add any keywords, and even create your own:\n\n```js\nimport {compile, keywords} from 'goldstein';\n\nconst source = `\n    fn hello() {\n        return id('hello');\n    }\n`;\n\nconst {keywordFn} = keywords;\n\ncompile(source, {\n    keywords: {\n        ...keywords,\n        keywordFn: null,\n        keywordId(Parser) {\n            const {keywordTypes} = Parser.acorn;\n            \n            return class extends Parser {};\n        },\n    },\n    rules: {\n        declare: ['on', {\n            declarations: {\n                id: 'const id = (a) =\u003e a',\n            },\n        }],\n    },\n});\n\n// returns\n`\nconst id = (a) =\u003e a;\n\nfunction hello() {\n    return id('hello');\n}\n`;\n```\n\nYou can declare variables with [`@putout/operator-declare`](https://github.com/coderaiser/putout/tree/master/packages/operator-declare).\n\n### `parse(source, {type, keywords})`\n\nWhen you need to get **JavaScript** Babel AST use `parse`:\n\n```js\nimport {parse} from 'goldstein';\n\nparse(`\n    fn hello() {\n        guard text !== \"world\" else {\n            return \"\"\n        }\n        \n        return \"Hello \" + text\n    }\n`);\n\n// returns Babel AST\n```\n\nYou can parse to **ESTree**:\n\n```js\nconst options = {\n    type: 'estree',\n};\n\nparse(`\n    fn hello() {\n        guard text !== \"world\" else {\n            return \"\"\n        }\n        \n        return \"Hello \" + text\n`, options);\n```\n\n### `print(ast)`\n\nYou can make any modifications to **Goldstein AST** and then `print` back to **Goldstein**:\n\n```js\nimport {parse, print} from 'goldstein';\n\nconst ast = parse(`const t = try f('hello')`);\nconst source = print(ast);\n```\n\n### `convert(source)`\n\nYou can even convert **JavaScript** to **Goldstein** with:\n\n```js\nimport {convert} from 'goldstein';\n\nconst ast = convert(`const t = tryCatch(f, 'hello')`);\n\n// returns\n`const t = try f('hello')`;\n```\n\n## Keywords\n\n**Goldstein** is absolutely compatible with JavaScript, and it has extensions.\nHere is the list.\n\n### `fn`\n\nYou can use `fn` to declare a `function`:\n\n```rust\nfn hello() {\n    return 'world';\n}\n```\n\nThis is the same as:\n\n```js\nfunction hello() {\n    return 'world';\n}\n```\n\n### `append array`\n\nAppend new elements to an array just like in Swift:\n\n```js\nlet a = [1];\n\na += [2, 3];\n```\n\nIs the same as:\n\n```js\nconst a = [1];\na.push(...[2, 3]);\n```\n\n### `guard`\n\nApplies not to `IfCondition`:\n\n```swift\nfn hello() {\n    guard text !== \"world\" else {\n        return \"\"\n    }\n\n    return \"Hello \" + text\n}\n```\n\nIs the same as:\n\n```js\nfunction hello() {\n    if (text === 'world') {\n        return '';\n    }\n    \n    return `Hello ${text}`;\n}\n```\n\n### `try`\n\n`try` can be used as an expression.\n\nApplies [`tryCatch`](https://github.com/coderaiser/try-catch):\n\n```gs\nconst [error, result] = try hello('world');\n```\n\nIs the same as:\n\n```js\nimport {tryCatch} from 'try-catch';\n\nconst [error, result] = tryCatch(hello, 'world');\n```\n\nand\n\n```gs\nconst [error, result] = try await hello('world');\n```\n\nIs the same as:\n\n```js\nimport tryToCatch from 'try-catch';\n\nconst [error, result] = await tryToCatch(hello, 'world');\n```\n\n### [`operator-safe-assignment`](https://github.com/arthurfiorette/proposal-safe-assignment-operator)\n\nYou can use `?=` instead of [`try`](#try):\n\n```gs\nconst [error, result] ?= hello('world');\n```\n\nIs the same as:\n\n```js\nimport {tryCatch} from 'try-catch';\n\nconst [error, result] = tryCatch(hello, 'world');\n```\n\nand\n\n```gs\nconst [error, result] ?= await hello('world');\n```\n\nIs the same as:\n\n```js\nimport tryToCatch from 'try-catch';\n\nconst [error, result] = await tryToCatch(hello, 'world');\n```\n\n### `should`\n\n`should` can be used as an expression (just like [`try`](https://github.com/coderaiser/goldstein/edit/master/README.md#try)).\nThis keyword is useful if you want to prevent a function call (also async) to throw an error because you don't need to have any result and the real execution is just optional (so runs if supported).\n\n```gs\nshould hello()\n```\n\nIs the same as:\n\n```gs\ntry hello();\n```\n\n\u003e ☝️ *Warning: this feature can be helpful but also dangerous especially if you're debugging your application. In fact, this is made to be used as an optional function call (ex. should load content, but not necessary and knowing this feature is optional), if you call a function in this way while debugging, no error will be printed and the application will continue run as nothing happened.*\n\n### `freeze`\n\nYou can use `freeze` instead of `Object.freeze()` like that:\n\n```gs\nfreeze {\n    'example': true\n}\n```\n\nIs the same as:\n\n```js\nObject.freeze({\n    example: true,\n});\n```\n\n### `if`\n\nYou can omit parens. But you must use braces in this case.\n\n```swift\nif a \u003e 3 {\n    hello();\n}\n```\n\nAlso you can use `if let` syntax:\n\n```swift\nif let x = a?.b {\n    print(x);\n}\n```\n\n### `throw expression`\n\nYou can use [throw as expression](https://github.com/tc39/proposal-throw-expressions), just like that:\n\n```js\nconst a = () =\u003e throw 'hello';\n```\n\n### `Curry`\n\nSimilar to [partial application](https://github.com/tc39/proposal-partial-application):\n\n```gs\nconst sum = (a, b) =\u003e a + b;\nconst inc = sum~(1);\n\ninc(5);\n// returns\n6\n```\n\n### `Import`\n\nWhen you import `.gs` files during compile step it will be replaced with `.js`:\n\n```gs\n// hello.js\nexport const hello = () =\u003e 'world';\n\n// index.js1\nimport hello from './hello.gs';\n```\n\nWill be converted to:\n\n```js\n// index.js\nimport hello from './hello.js';\n```\n\nAlso, also supported:\n\n```gs\nimport hello from hello;\n```\n\nAnd will be converted to:\n\n```js\nimport hello from 'hello';\n```\n\n### `FunctionDeclaration` with `Arrow`\n\nIf you mistakenly put `=\u003e` in function declaration:\n\n```gs\nfunction hello() =\u003e {\n}\n```\n\nThat absolutely fine, it will be converted to:\n\n```js\nfunction hello() {}\n```\n\n### Broken String\n\nWhen you accidentally broke string, Goldstein will fix it:\n\n```diff\n-const a = 'hello\n+const a = 'hello';\n-const a = ‘hello world’;\n+const a = 'hello world';\n```\n\n### Missing Initializer\n\nForget to add assignment (`=`), not problem!\n\n```diff\n-const {code, places} await samadhi(source);\n+const {code, places} = await samadhi(source);\n```\n\n### Useless comma\n\nAdded useless comma (`,`)? no problem!\n\n```diff\nconst a = {\n-    b,,\n+    b,\n};\n```\n\n### Useless semicolon\n\nAdded useless semicolon (`;`)? no problem!\n\n```diff\nconst a = {\n-    b;\n+    b,\n};\n\nconst a = {\n-    b(){},\n+    b(){}\n};\n```\n\n### Assign from\n\n```gs\nconst a = from 'a';\n```\n\nThe same as:\n\n```js\nconst a = require('a');\n```\n\n### Export without `const`\n\n```gs\nexport x = () =\u003e {};\n```\n\nThe same as:\n\n```js\nexport const x = () =\u003e {};\n```\n\n### `export default from`\n\n[ECMAScript Proposal: export default from](https://github.com/tc39/proposal-export-default-from).\n\n```js\nexport hello from './x.js';\n```\n\nThe same as:\n\n```js\nexport {default} from './x.js';\n```\n\n### Wrong brace `)`\n\n```diff\n-import a from 'a');\n+import a from 'a';\n```\n\n## How to contribute?\n\nClone the registry, create a new keyword with a prefix `keyword-`, then create directory `fixture` and put there two files with extensions `.js` and `.gs`. Half way done 🥳!\n\nThen goes test and implementation in `index.js1` and `index.spec.js` accordingly. Use scripts:\n\n- `npm test`\n- `UPDATE=1 npm test` - update `fixtures`;\n- `AST=1 npm test` - log `AST`;\n- `npm run coverage`;\n- `npm run fix:lint`;\n\nUpdate docs and make PR, that's it!\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderaiser%2Fgoldstein","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoderaiser%2Fgoldstein","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderaiser%2Fgoldstein/lists"}