如何使用livescript列出所有方法?

时间:2014-04-03 04:41:08

标签: livescript

在python中有dir(模块):

In [6]: dir(datetime) Out[6]: ['MAXYEAR', 'MINYEAR', '__doc__', '__file__', '__name__', '__package__', 'date', 'datetime', 'datetime_CAPI', 'time', 'timedelta', 'tzinfo']

Elixir你可以输入模块名,然后按tab键,然后它会列出方法所具有的所有功能。

iex(1)> String. Chars at/2 capitalize/1
codepoints/1 contains?/2 downcase/1
duplicate/2 ends_with?/2 first/1
from_char_list!/1 from_char_list/1 graphemes/1
last/1 length/1 ljust/2
ljust/3 lstrip/1 lstrip/2
match?/2 next_codepoint/1 next_grapheme/1

在红宝石中,你有methods

[2] pry(main)> File.methods => [:directory?, :exist?, :exists?, :readable?, :readable_real?, :world_readable?, :writable?, :writable_real?, :world_writable?, :executable?, :executable_real?, :file?, :zero?, :size?, ...]

是否有相同的文字?

1 个答案:

答案 0 :(得分:2)

也许使用prelude.ls中的函数 - keys - http://preludels.com/#keys

编辑:

使用-d标志自动将prelude.ls导入到repl。

$ lsc -d
LiveScript 1.2.0 - use 'lsc --help' for more information
ls> keys require 'assert'
[ 'AssertionError',
  'fail',
  'ok',
  'equal',
  'notEqual',
  'deepEqual',
  'notDeepEqual',
  'strictEqual',
  'notStrictEqual',
  'throws',
  'doesNotThrow',
  'ifError' ]