Lawnchair.js - retrieve boolean from 'exists' method

For those who use or have used THIS code, please tell me how to get a boolean value from the exists function. It returns an object, and I can't find any boolean values inside it.

Answers


Never used this, but found this within a single click.

searching keys is annoying and tedious. gawd! but wait...

// test for existence of a key
lawnchair(function(){
  this.exists('my-key-name', function(exists) {
    console.log(exists)
  })
})

What does that print into your console? Removing the string should help debug the issue.

EDIT - After digging around, there are two definitions for the exists function.

exists: function (key, cb) {
  this.lambda(cb).call(this, !!(store[key]))
  return this
}

And

exists: function (key, cb) {
    var exists = this.indexer.find(this.name+'.'+key) === false ? false : true ;
    this.lambda(cb).call(this, exists);
    return this;
}

They both should return boolean values. The first one might be a bit suspicious. Not sure. Try including the expanded JS version with the comments and breakpoint in the Lawnchair functions. You'll find what's going on in no time.

Sleep time here :) Good luck.


Never used it, but the documentation suggests that your callback function to exists will receive a boolean argument:

// test for existence of a key
lawnchair(function(){
    this.exists('my-key-name', function(exists) {
        console.log('existence is: ' + exists)
    })
})

Need Your Help

Parsing XML from NSString to get values

iphone ios ios5 xml-parsing

This question is for manipulating NSString in xcode.