# f = (stack) ->
#   if !stack? or stack is false or stack is ''
#     stack = []
#   else
#     unless Array.isArray(stack)
#       stack = stack.toString().split('.')
#   stack
#
#
# console.log f()
# console.log f(undefined)
# console.log f(false)
# console.log f(true)
# console.log f(0)
# console.log f(1)
# console.log f(3.3)
# console.log f([])
# console.log f([null])
# console.log f([1, 2, 3])
#

# { diff } = require './src'
# console.log diff { "foo": 1 }, { "foo": 2.5 }, null, { inc: true }

$ = require './src'
# console.log apply {}, { "$inc": { "foo.bar": 1 } }
# console.log apply { "foo": 1.5 }, { "$inc": { "foo": -2.5 } }
# console.log apply { "foo": 1, "bar": 2 }, { "$unset": { "foo": true }, "$set": { "a.b": 3 } }

# console.log $.diff {foo:1}, {foo:null}
# console.log $.diff {foo:new Date}, {foo:null}

# console.log $.diff { foo: [1, 2, 3] }, { foo: null }
# console.log $.diff { foo: null }, { foo: [1, 2, 3] }
# console.log $.diff { foo: [1, 2, 3] }, { foo: [1, null, 3] }
# console.log $.diff { foo: [1, null, 3] }, { foo: [1, 2, 3] }

# a = { foo: [ 'a', 'b', 'c', 'd', 'e' ] }
# b = { foo: [ 'b', 'c', 'd', 'e' ] }
# console.log d = $.diff a, b
# console.log JSON.stringify $.apply a, d

# { '$rename': { 'a.1': 'a.0' } }

# console.log $.diff {a:['a','b']}, {a:['b']}
# console.log $.apply {a:['a','b']}, { '$rename': { 'a.1': 'a.0' } }

# console.log { '$unset' : {'a.0':true} }, $.diff {a:['a','b']}, {a:['b']}

# extjson = require 'extjson'
# console.log extjson.encode { foo: new Date }

{ ObjectId } = require 'bson/lib/bson/objectid'
# d = {
#   _id: ObjectId()
#   foo: 'FOO'
#   bar: undefined
# }
# console.log $.diff d, {}

for own k, v of ObjectId()
  console.log k, v
