mirror of
https://github.com/fazo96/pbs.git
synced 2025-01-29 14:54:18 +01:00
more options added to PBSlib
This commit is contained in:
parent
265f3bc7f8
commit
0ad54bee53
@ -1,7 +1,14 @@
|
|||||||
class PBS
|
class PBS
|
||||||
constructor: (@list, @verbose) ->
|
constructor: (obj, @verbose, @errListener) ->
|
||||||
@days = []
|
@days = []
|
||||||
@criticalPaths = []
|
@criticalPaths = []
|
||||||
|
if obj.push # is a list
|
||||||
|
@list = obj
|
||||||
|
else if obj.activities
|
||||||
|
@list = obj.activities
|
||||||
|
else
|
||||||
|
@list = []
|
||||||
|
@err 'data is not an array nor a object with "activities" array'
|
||||||
|
|
||||||
log: (x...) ->
|
log: (x...) ->
|
||||||
if @verbose
|
if @verbose
|
||||||
@ -10,8 +17,9 @@ class PBS
|
|||||||
else console.log "[ Pert ]", x...
|
else console.log "[ Pert ]", x...
|
||||||
err: (x...) ->
|
err: (x...) ->
|
||||||
if chalk?
|
if chalk?
|
||||||
console.log chalk.bold chalk.red("[ !Pert! ]"), x...
|
console.log chalk.bold chalk.red("[ Pert ]"), x...
|
||||||
else console.log "[ !Pert! ]", x...
|
else console.log "[ !Pert! ]", x...
|
||||||
|
if @errListener?.call? then @errListener x
|
||||||
|
|
||||||
# Returns the highest number in an array of numbers
|
# Returns the highest number in an array of numbers
|
||||||
maxa: (l) -> return Math.max.apply null, l
|
maxa: (l) -> return Math.max.apply null, l
|
||||||
@ -123,3 +131,6 @@ class PBS
|
|||||||
else
|
else
|
||||||
if cb? then cb(results)
|
if cb? then cb(results)
|
||||||
results
|
results
|
||||||
|
|
||||||
|
# export module to node environment
|
||||||
|
if module?.exports? then module.exports = PBS
|
||||||
|
Loading…
Reference in New Issue
Block a user