bevacqua / local-storage

:left_luggage: A simplified localStorage API that just works
https://ponyfoo.com
MIT License
523 stars 62 forks source link

Modify remove function to return a boolean. #11

Closed schmarjames closed 8 years ago

schmarjames commented 8 years ago

Modified remove function to return a boolean based on the success of removing a key from the local storage. This could be a convenience syntax wise to simply check if data has been removed.

bevacqua commented 8 years ago

Is there a case when data is not removed?

schmarjames commented 8 years ago

If the data isn't removed it will return false. The localStorage function "getItem" will return null if the key doesn't exist. Anything else means that the key still exist and the function will return false.

In any case if the user passes a key that does exist in the local storage it will be removed. This is just a way to determine if the remove was successful. The function ls.remove('keyName') can be passed to an if/else conditional. Besides the documentation states that it will return a boolean yet it doesn't.

bevacqua commented 8 years ago

You didn't answer my question, though

schmarjames commented 8 years ago

The answer to your question is no.