{"id":18790165,"url":"https://github.com/monsterkodi/kode","last_synced_at":"2026-03-05T05:30:58.860Z","repository":{"id":45647373,"uuid":"430871720","full_name":"monsterkodi/kode","owner":"monsterkodi","description":"programming language that transpiles to JavaScript","archived":false,"fork":false,"pushed_at":"2025-02-28T22:49:59.000Z","size":6911,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-06T22:02:55.762Z","etag":null,"topics":["javascript","kode","programming-language","transpiled-language"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/monsterkodi.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2021-11-22T21:35:05.000Z","updated_at":"2025-02-28T22:50:03.000Z","dependencies_parsed_at":"2024-03-17T20:47:56.893Z","dependency_job_id":null,"html_url":"https://github.com/monsterkodi/kode","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/monsterkodi/kode","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monsterkodi%2Fkode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monsterkodi%2Fkode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monsterkodi%2Fkode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monsterkodi%2Fkode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/monsterkodi","download_url":"https://codeload.github.com/monsterkodi/kode/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monsterkodi%2Fkode/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30111743,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T03:40:26.266Z","status":"ssl_error","status_checked_at":"2026-03-05T03:39:15.902Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["javascript","kode","programming-language","transpiled-language"],"created_at":"2024-11-07T21:10:10.274Z","updated_at":"2026-03-05T05:30:58.823Z","avatar_url":"https://github.com/monsterkodi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"./bin/kode.svg\" /\u003e\n\n**kode** is a programming language that transpiles to JavaScript.\n\nIt is highly inspired by and *tries* to be compatible with [CoffeeScript](http://coffeescript.org), while adding some features and further its minimalistic approach:\n\n## ...\n\n```kode\na = 1...3\nfor i in 0..5\n```\n\nSquare brackets around ranges are optional.\n\n## console\n\n```kode\nlog 'hello'     ▸ hello\nerror 'world!'  ▸ world!\n```\n\nSimple shortcuts for `log`, `warn` and `error` methods of `console`.\n\n## negative indexing\n\n```kode\n\"abc\"[-2]       ▸ 'b'\n[1,2,3][-2]     ▸ 2\n```\n\n`v[-n]` is a shortcut for `v[-n..-n][0]` for number literals `n`\n\n## if\n\n```kode\nif  \n    a ➜ X\n    b ➜ Y\n      ➜ Z\n```\nis a shortcut for\n\n```kode\nif      a then X\nelse if b then Y\n          else Z\n```\n\n\u003cimg src=\"./bin/cli.png\" /\u003e\n\n## switch\n\n```kode\nswitch x\n    1\n    2 3   ➜ X\n    'abc' ➜ Y\n          ➜ Z      \n```\nis a shortcut for\n\n```kode\nswitch x\n    when 1,2,3 then X\n    when 'abc' then Y\n    else            Z\n```\n\n\u003cimg src=\"./bin/switch.png\" /\u003e\n\n## is\n\n```kode\n1 is 'number' and '' is 'string' and {} is Object and [] is Array   ▸ true\n1 is Number or '' is String or [] is 'array'                        ▸ false\n```\n\n`is` is a shortcut for `typeof` and `instanceof`. \nThe first is used, when the right hand side is a string.\n\n### num str obj\n\n```kode\n\"0xFF\" is num and \"-4.536\" is num and 42 is num                     ▸  true\n'' is str and \"a\" is str and new String(\"abc\") is str               ▸  true\n{} is obj and new Object() is obj                                   ▸  true\nnull is obj or new Map() is obj or [] is obj                        ▸  false\n```\n\n`is num` does a string coersion via `parseFloat` in the test.\n`is str` checks both, type == 'string' or instanceof String.\n`is obj` evaluates to true for plain Objects only.\n\n## empty\n\n```kode\nempty [] and empty {} and empty '' and empty null and empty NaN     ▸ true\nempty 0 or empty 'a' or empty [null] or empty Infinity              ▸ false\n```\n\nReturns true for null, undefined, NaN and empty array, object or string.\n\n## valid\n\n```kode\nvalid 0 and valid 'a' and valid [null] and valid Infinity           ▸ true\nvalid [] or valid {} or valid '' or valid null or valid NaN         ▸ false\n```\n\nJust the negation of `empty`.\n\n## each\n\n```kode\nobj each (k,v) -\u003e [k,v]\nobj each (v) -\u003e v\n```\n\nThe `each` operator takes an object, array or string on the left hand side and \na function on the right hand side.\nThe function is called for each key/value, index/item, index/character pair.\nA new object, array or string is build from the results and returned:\n\n```kode\n'hello'   each (c) -\u003e c+c                                           ▸ 'hheelllloo'\n[1,3]     each (i,v) -\u003e [1-i,v*v]                                   ▸ [9,1]\n{a:1,b:3} each (k,v) -\u003e ['▸'+k, k+v]                                ▸ { '▸a': 'a1', '▸b': 'b3' }\n```\n\nIf the function takes only one argument, \nit is the value/item/character and a single return value is expected.\n\n## for\n\n```kode\nx = null\nfor a in x\n    log 'hello'\n```\n\nThe above code would throw an exception at runtime in CoffeeScript.\n**kode** generates code that doesn't fail if x is not an array.\n\n## constructor\n\n```kode\nclass C\n    @: -\u003e\n```\n\nis a shortcut for\n\n```kode\nclass C\n    constructor: -\u003e\n```\n\n## list comprehension\n\n```kode\nl = [1,2,3]\na = [x for x in l]                                                  ▸ [1,2,3]\na = (x for x in l)                                                  ▸ [1,2,3]\n````\n\n**kode** doesn't distuinguish between round and square brackets around list comprehensions.\n\n## ternary\n\n```kode\nfalse ? 1 : 2                                                       ▸ 2\n```\n\nA nifty `if` `then` `else` shortcut.\nIt introduces some ambiguity in a few corner cases, which can be resolved by different spacing:\n\n```kode\nnull ? a: 'b'                                                       ▸ {a:'b'}\n```\n\n## old school\n\n**kode** gives you the option to use the old school `function` style classes of CoffeeScript v1:\n\n```kode\nfunction C\n    @: -\u003e\n```\n\nThe generated code might be a bit more ugly, but the function based classes don't suffer from some of the limitations of the new class syntax.\nFor example, keywords can be used as method names and super doesn't have to be called first in the constructor.\nNew and old school styles can be used in the same module, but obviously not in the same class hierarchy.\n\n## optional commata\n\nCoffeeScript has a very nice way of initializing arrays:\n\n```kode\na = [\n        1\n        2\n        3\n    ]\n```\n\nIf you decide to join these into a single line, you have a problem: \nfor each of the lines a comma must be inserted.\nThe same goes for objects that span over multiple lines.\n\nIn **kode**, you don't need to insert commata after number or string literals and POD structures.\nThose are all valid expressions:\n\n```kode\na = [ 1 2 3 ]\na = { b:1 c:2 d:3 }\na =   b:1 c:2 d:3\na =   b:[ c:2 'd' 3 ]\na = [ [1 2] [d:3] ]\n\ntest 'something' -\u003e\n    it 'should' -\u003e\n\non 'event' @myCallback\n\nlog 'a:' a , 'd:' 3                     # some commas still make sense :-)\n```\n\n## noon\n\n```kode\ns = noon a:1 b:2\nlog s                                   ▸ a   1\n                                        ▸ b   2\n```\n\nOperator that converts argument into string in [noon](https://github.com/monsterkodi/noon) notation.\nHandles recursion, unlike `JSON.stringify`.\n\n## dbg\n\n```kode\nmyObj = a:1 b:2 c:d:3\ndbg myObj                               ▸ file.kode:2:0 myObj\n                                        ▸ a   1\n                                        ▸ b   2\n                                        ▸ c\n                                        ▸     d   3\ndbg '1st' 0 '2nd' myObj.c               ▸ file.kode:7:0\n                                        ▸ 1st 0 2nd d   3\n```\n\nLogs file and position followed by arguments in [noon](https://github.com/monsterkodi/noon) notation.\nIf first argument is an identifier, appends its name to the file position.\n\n## assert\n\n```kode\nf = (a) -\u003e ▴ a ; a                      ▸ file.kode:1:11 ▴ assert failed! a\n▴ 'good' f 1                            \n▴ 'bad'  f 0                            ▸ file.kode:3:0 ▴ bad f(0)\n```\n\nLogs file position, message and condition code if condition isn't truish. \nIf message is omitted, 'assert failed!' will be used.\n\n## profile\n\n```kode\n●▸ sunny times\n\nfun = -\u003e                              \n    ● funny times                     \n    Math.sqrt x for x in 0..100000    \n                                      \nfun() for i in 1..2                     ▸ funny times 12 ms\n                                        ▸ funny times 11 ms\n●▪ sunny times                          ▸ sunny times 26 ms\n```\n\nLogs time difference between matching `●▸` `●▪` pairs.\n\n`●` is a shortcut that can be used in functions: `●▪` is inserted automatically before the function returns.\n\n`process.hrtime.bigint` is used for the timing and the measurements come with *μs* accuracy.\nDue to JavaScripts just in time compilation optimizations, the initial results might be greater than later runs.\n    \n## copy \u0026 clone\n\n```\na = copy b                              # shallow copy of b\na = clone b                             # deep copy of b\n```\n\nOperators that return a shallow or deep copy of their argument. \nOnly plain Objects, Arrays and Strings are copied. Functions, Maps, Sets, etc. are not copied.\n\n## eql\n\n```\na eql b                                 # deep comparison\n```\n\nDoes a deep comparison of its operands. \nOnly plain Objects, Arrays and Strings are compared.\n\n## tests \n\n**kode** comes with its own testing 'framework' (in quotes here, because it's too much of a word for such a minimalistic thing:)\n\n```\n▸ test\n    ▸ sub test\n        something      ▸ result\n        something else ▸ other result\n```\n\nIf the `▸` has nothing on its left hand side, it denotes a test section.\nOtherwise the expressions on both sides are compared. The files in `kode/test` provide plenty of examples how to use this:\n\n\u003cimg src=\"./bin/tets.png\" /\u003e\n\nthe output of two runs:\n\n\u003cimg src=\"./bin/test.png\" /\u003e\n\n## ansi colors\n\n```\nlog Y5 r2 'warning!'   ▸ output in dark red on bright yellow\n```\n\n**kode** injects ansi color code wrappers if it discovers function calls with names like `R1` or `g8`.\nColor functions: 'r' 'g' 'b' 'c' 'm' 'y' 'w' for foreground (uppercase for background) and a number between 1 and 8.\n\n# Compatibility\n\n**kode** is *mostly* compatible with CoffeeScript. Converting to **kode** shouldn't be too painful.\n\nStuff I rarely used and therefore didn't bother to re-implement:\n\n- literal coffeescript\n- `unless`  `until` `or=` `by` ...\n- `when` outside of `switch`\n- wrapper code\n- string interpolation in object keys\n- implicitly returning arrays if last expression is a loop\n\n# features to add\n- `use` keyword for import\n- `include` keyword to merge source files\n- render comments\n- sourcemaps\n- error messages\n\n# bugs\n▸ `return` issues\n- trailing if after obj args: `@func obj:1 if truish`\n- indentation issue in else branches:\n    ```\n    if 1 then \n    else # this works\n        @s = Immutable \n                lines:lines\n    \n    if 1 then\n    else # this doesn't :(\n        @s = Immutable \n            lines:lines\n    ```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonsterkodi%2Fkode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmonsterkodi%2Fkode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonsterkodi%2Fkode/lists"}