1 | module.exports = class Tuple
|
2 |
|
3 | @isHash: (data) ->
|
4 | return false if !data or data instanceof Array or typeof data != "object"
|
5 | return true
|
6 |
|
7 | @DEFAULT = {expire: 300}
|
8 |
|
9 | constructor: (@data) ->
|
10 | @__defineSetter__ 'expire', (sec) ->
|
11 | @expire_at = Math.floor(Date.now()/1000)+sec
|
12 | @expire = 300
|
13 |
|
14 | match: (tuple) ->
|
15 | return false unless Tuple.isHash(tuple)
|
16 | data = if tuple instanceof Tuple then tuple.data else tuple
|
17 | for k,v of @data
|
18 | if typeof v == 'object'
|
19 | return false if typeof data[k] != 'object'
|
20 | return false if JSON.stringify(v) != JSON.stringify(data[k])
|
21 | else
|
22 | return false if v != data[k]
|
23 | return true
|