Changed lume.fn/once's returned func return, v1.0.8

* The functions which lume.fn() and lume.once() return now return their
  inner functions' return value instead of nil
* Moved lume.once() in lume.lua and README.md to be near its similar
  functions -- lume.fn() and lume.time()
This commit is contained in:
rxi
2014-03-02 00:09:24 +00:00
parent d65556bc83
commit 842e367ccd
2 changed files with 23 additions and 20 deletions

View File

@@ -121,15 +121,6 @@ exist in the table.
lume.find({"a", "b", "c"}, "b") -- Returns 2
```
### lume.once(fn, ...)
Returns a wrapper function to `fn` which takes the supplied arguments. The
wrapper function will call `fn` on the first call and do nothing on any
subsequent calls.
```lua
local f = lume.once(print, "Hello")
f() -- Prints "Hello"
f() -- Does nothing
```
### lume.slice(t [, i [, j]])
Mimics the behaviour of Lua's `string.sub`, but operates on an array rather
@@ -149,6 +140,16 @@ local f = lume.fn(print, "Hello")
f() -- Prints "Hello"
```
### lume.once(fn, ...)
Returns a wrapper function to `fn` which takes the supplied arguments. The
wrapper function will call `fn` on the first call and do nothing on any
subsequent calls.
```lua
local f = lume.once(print, "Hello")
f() -- Prints "Hello"
f() -- Does nothing
```
### lume.time(fn, ...)
Inserts the arguments into function `fn` and calls it. Returns the time in
seconds the function `fn` took to execute followed by `fn`'s returned values.