CoffeeScript 功能加强

CoffeScript makes javascript fun, and the CoffeeScript's source code write clearly and easy to extend, I add 2 string related features: Ruby symbol like string and long string.

CoffeeScript让javascript变得有趣,而且代码清晰,易用扩展,我在CoffeeScript的原基础上加入2个新字符串相关的语法。一个是类似Ruby Symbol的字串,一个是超长字串

1. Ruby Symbol like

CoffeeScript:
console.info :hello, :world
JavaScript:
console.info('hello', 'world');
Remark:
What will be translated to for those code?
1. info:hello
{info: hello}

2. {:hello, :world}
ERROR! use {hello, world} instead

2. 正则表达示运算符

if :hello =~ /^\w+$/
  console.info :ok, \&
生成
var __matches = null;
if (__matches = 'hello'.match(/^\w+$/)) 
  console.info('ok', __matches[0]);

3. Links

My forked CoffeeScript GitHub Repo with those 2 features
Original CoffeeScript GitHub Repo

发表评论

电子邮件地址不会被公开。 必填项已被标记为 *

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>