{"id":31921847,"url":"https://github.com/rmw-lib/coffee-label-patch","last_synced_at":"2026-07-18T20:34:49.276Z","repository":{"id":41392552,"uuid":"473888482","full_name":"rmw-lib/coffee-label-patch","owner":"rmw-lib","description":null,"archived":false,"fork":false,"pushed_at":"2022-07-04T06:28:49.000Z","size":74,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-05-19T00:48:08.575Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","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/rmw-lib.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}},"created_at":"2022-03-25T06:05:18.000Z","updated_at":"2025-11-05T14:32:36.000Z","dependencies_parsed_at":"2022-07-29T22:49:31.001Z","dependency_job_id":null,"html_url":"https://github.com/rmw-lib/coffee-label-patch","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/rmw-lib/coffee-label-patch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmw-lib%2Fcoffee-label-patch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmw-lib%2Fcoffee-label-patch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmw-lib%2Fcoffee-label-patch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmw-lib%2Fcoffee-label-patch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rmw-lib","download_url":"https://codeload.github.com/rmw-lib/coffee-label-patch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmw-lib%2Fcoffee-label-patch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35630866,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-18T02:00:07.223Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-10-13T22:55:04.673Z","updated_at":"2026-07-18T20:34:49.260Z","avatar_url":"https://github.com/rmw-lib.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- 本文件由 ./readme.make.md 自动生成，请不要直接修改此文件 --\u003e\n\n# @rmw/coffee-label-patch\n\nMake coffeescript support :label syntax (similar to [livescript](https://livescript.net)) so that it can be used for [svelte](https://svelte.dev).\n\nIt's too hard to modify the compiler based on lex, ast, and I did this based on string substitution.\n\nThis is just a crude hack, but it does work.\n\nExpect coffee to officially add this syntax.\n\n##  Install\n\n```yarn add @rmw/coffee-label-patch ``` or ``` npm install @rmw/coffee-label-patch```\n\n## Use\n\n```coffee\n#!/usr/bin/env coffee\n\nimport CoffeeScript from \"coffeescript\"\nimport hack from '@rmw/coffee-label-patch'\nhack CoffeeScript\nconsole.log CoffeeScript.compile(\n  \"\"\"\ny = 0\n\n:$ x=y*2\n\n:$ if y\u003e2 then x+=y else x-=y\n\n:$\n  if x \u003e y\n    x = y/2\n  else\n    x = y+9\n  x += 1\n\ndo =\u003e\n  + a,b\n\n:$ func = =\u003e 1\n\n:$ func = -\u003e\n  1\n  2\n\ndo =\u003e\n  :out\n    for i in [1,2,3]\n      for j in [4,5,6]\n        console.log i,j\n        if i \u003e 1\n          break out\n  return\n\n\u003c x\n\u003c x = 1\n\n  \"\"\"\n  bare:true\n  #  sourceMap:true\n)\n```\n\noutput :\n\n```js\nvar x, y;\n\ny = 0;\n\n$ : x = y * 2;\n\n$ : y \u003e 2 ? x += y : x -= y;\n\n$ : {\n  if (x \u003e y) {\n    x = y / 2;\n  } else {\n    x = y + 9;\n  }\n  x += 1;\n}\n\n(() =\u003e {\n  var i, j, k, l, len, len1, ref, ref1;\n  out : {\n    ref = [1, 2, 3];\n    for (k = 0, len = ref.length; k \u003c len; k++) {\n      i = ref[k];\n      ref1 = [4, 5, 6];\n      for (l = 0, len1 = ref1.length; l \u003c len1; l++) {\n        j = ref1[l];\n        console.log(i, j);\n        if (i \u003e 1) {\n          break out;\n        }\n      }\n    }\n  }\n})();\n```\n\nthen `node test.out.js` , stdout is\n\n```\n1 4\n1 5\n1 6\n2 4\n```\n\n## 中文说明\n\n让 coffeescript 支持 :label 语法（类似 livescript），这样就可以用于 [svelte](https://svelte.dev) 。\n\n基于 lex 、 ast 去修改编译器太难了，我基于字符串替换做到这个功能。\n\n这只是一个粗糙的hack。但它的确能工作。\n\n期待coffee正式加入此语法。\n\n## 关于\n\n本项目隶属于**人民网络([rmw.link](//rmw.link))** 代码计划。\n\n![人民网络](https://raw.githubusercontent.com/rmw-link/logo/master/rmw.red.bg.svg)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frmw-lib%2Fcoffee-label-patch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frmw-lib%2Fcoffee-label-patch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frmw-lib%2Fcoffee-label-patch/lists"}