Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear luacheck warnings #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions rx.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
local util = {}

util.pack = table.pack or function(...) return { n = select('#', ...), ... } end
util.unpack = table.unpack or unpack
util.unpack = table.unpack or _G.unpack
util.eq = function(x, y) return x == y end
util.noop = function() end
util.identity = function(x) return x end
Expand Down Expand Up @@ -133,7 +133,7 @@ end

--- Returns an Observable that never produces values and never completes.
function Observable.never()
return Observable.create(function(observer) end)
return Observable.create(function() end)
end

--- Returns an Observable that immediately produces an error.
Expand Down Expand Up @@ -657,8 +657,6 @@ function Observable:debounce(time, scheduler)

local function wrap(key)
return function(...)
local value = util.pack(...)

if debounced[key] then
debounced[key]:unsubscribe()
end
Expand Down Expand Up @@ -1829,6 +1827,7 @@ function Observable.zip(...)
table.insert(values[i], value)
values[i].n = values[i].n + 1

-- luacheck: ignore i
local ready = true
for i = 1, count do
if values[i].n == 0 then
Expand Down Expand Up @@ -1890,6 +1889,7 @@ end
--- Schedules a function to be run on the scheduler. It is executed immediately.
-- @arg {function} action - The function to execute.
function ImmediateScheduler:schedule(action)
local _ = self
action()
end

Expand Down Expand Up @@ -1993,8 +1993,8 @@ end
-- @arg {number=0} delay - The delay, in milliseconds.
-- @returns {Subscription}
function TimeoutScheduler:schedule(action, delay, ...)
local _ = self
local timer = require 'timer'
local subscription
local handle = timer.setTimeout(delay, action, ...)
return Subscription.create(function()
timer.clearTimeout(handle)
Expand Down Expand Up @@ -2315,4 +2315,4 @@ return {
AsyncSubject = AsyncSubject,
BehaviorSubject = BehaviorSubject,
ReplaySubject = ReplaySubject
}
}
3 changes: 2 additions & 1 deletion src/observable.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
local Observer = require 'observer'
local util = require 'util'

--- @class Observable
Expand Down Expand Up @@ -38,7 +39,7 @@ end

--- Returns an Observable that never produces values and never completes.
function Observable.never()
return Observable.create(function(observer) end)
return Observable.create(function() end)
end

--- Returns an Observable that immediately produces an error.
Expand Down
1 change: 1 addition & 0 deletions src/operators/amb.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local Observable = require 'observable'
local Subscription = require 'subscription'

--- Given a set of Observables, produces values from only the first one to produce a value.
-- @arg {Observable...} observables
Expand Down
1 change: 1 addition & 0 deletions src/operators/combineLatest.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local Observable = require 'observable'
local Subscription = require 'subscription'
local util = require 'util'

--- Returns a new Observable that runs a combinator function on the most recent values from a set
Expand Down
2 changes: 0 additions & 2 deletions src/operators/debounce.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ function Observable:debounce(time, scheduler)

local function wrap(key)
return function(...)
local value = util.pack(...)

if debounced[key] then
debounced[key]:unsubscribe()
end
Expand Down
2 changes: 1 addition & 1 deletion src/operators/flatten.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local Observable = require 'observable'
local util = require 'util'
local Subscription = require 'subscription'

--- Returns a new Observable that subscribes to the Observables produced by the original and
-- produces their values.
Expand Down
1 change: 1 addition & 0 deletions src/operators/merge.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local Observable = require 'observable'
local Subscription = require 'subscription'

--- Returns a new Observable that produces the values produced by all the specified Observables in
-- the order they are produced.
Expand Down
1 change: 1 addition & 0 deletions src/operators/sample.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local Observable = require 'observable'
local Subscription = require 'subscription'
local util = require 'util'

--- Returns a new Observable that produces its most recent value every time the specified observable
Expand Down
1 change: 1 addition & 0 deletions src/operators/switch.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local Observable = require 'observable'
local Subscription = require 'subscription'

--- Given an Observable that produces Observables, returns an Observable that produces the values
-- produced by the most recently produced Observable.
Expand Down
1 change: 1 addition & 0 deletions src/operators/with.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local Observable = require 'observable'
local Subscription = require 'subscription'
local util = require 'util'

--- Returns an Observable that produces values from the original along with the most recently
Expand Down
2 changes: 2 additions & 0 deletions src/operators/zip.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local Observable = require 'observable'
local Subscription = require 'subscription'
local util = require 'util'

--- Returns an Observable that merges the values produced by the source Observables by grouping them
Expand Down Expand Up @@ -26,6 +27,7 @@ function Observable.zip(...)
table.insert(values[i], value)
values[i].n = values[i].n + 1

-- luacheck: ignore i
local ready = true
for i = 1, count do
if values[i].n == 0 then
Expand Down
1 change: 1 addition & 0 deletions src/schedulers/immediatescheduler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ end
--- Schedules a function to be run on the scheduler. It is executed immediately.
-- @arg {function} action - The function to execute.
function ImmediateScheduler:schedule(action)
local _ = self
action()
end

Expand Down
3 changes: 2 additions & 1 deletion src/schedulers/timeoutscheduler.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local Subscription = require 'subscription'
local util = require 'util'

--- @class TimeoutScheduler
-- @description A scheduler that uses luvit's timer library to schedule events on an event loop.
Expand All @@ -17,8 +18,8 @@ end
-- @arg {number=0} delay - The delay, in milliseconds.
-- @returns {Subscription}
function TimeoutScheduler:schedule(action, delay, ...)
local _ = self
local timer = require 'timer'
local subscription
local handle = timer.setTimeout(delay, action, ...)
return Subscription.create(function()
timer.clearTimeout(handle)
Expand Down
2 changes: 1 addition & 1 deletion src/util.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local util = {}

util.pack = table.pack or function(...) return { n = select('#', ...), ... } end
util.unpack = table.unpack or unpack
util.unpack = table.unpack or _G.unpack
util.eq = function(x, y) return x == y end
util.noop = function() end
util.identity = function(x) return x end
Expand Down
2 changes: 1 addition & 1 deletion tools/build.lua
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,6 @@ end
local file = io.open(destination, 'w')

if file then
file:write(table.concat(components, ''))
file:write(table.concat(components, ''), "\n")
file:close()
end