Skip to content

Instantly share code, notes, and snippets.

@Layzie
Created December 14, 2012 06:06
Show Gist options
  • Select an option

  • Save Layzie/4283050 to your computer and use it in GitHub Desktop.

Select an option

Save Layzie/4283050 to your computer and use it in GitHub Desktop.
v0.0.3.6 - v0.5 diff
diff --git a/.gitignore b/.gitignore
index ca35be0..a10754b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
_site
+node_modules/
diff --git a/README.md b/README.md
index f77a570..b8b975b 100644
--- a/README.md
+++ b/README.md
@@ -7,10 +7,15 @@ This library for easier using 'localStorage' & 'sessionStorage'.
See http://layzie.github.com/rockstage_js
## General usage
+
This script use no library yet. So add script tags in html when using it.
`<script src="/your/path/rockstage.js" type="text/javascrpt" charset="utf-8"></script>`
+Or you want to minified file then add below.
+
+`<script src="/your/path/rockstage.min.js" type="text/javascrpt" charset="utf-8"></script>`
+
### Set items to storage
`RS.put(object, flag)`
@@ -97,14 +102,28 @@ ex:
RS.is('hoge', true) // Check 'hoge' in localStorage
```
+### Check length of items from storage
+
+`RS.length(flag)`
+- `flag` is flag to selecting `localStorage` or `sessionStorage`.
+
+Use this method to know the length of storage.
+
+This argument default value is `true`. This is `localStorage`. Set to `false` when using
+`sessionStorage`.
+
+ex:
+```javascript
+RS.length(true) // Return the length of localStorage.
+```
## Test enviroments
This library tests below browsers.
-- Chrome 20.0.1132.47, OS X 10.7 (Lion)
-- Safari 5.1.7, OS X 10.7 (Lion)
-- Firefox 12.0, OS X 10.7 (Lion)
-- Opera 12.00, OS X 10.7 (Lion)
+- Chrome 21.0.1180.89, OS X 10.7 (Lion)
+- Safari 6.0, OS X 10.7 (Lion)
+- Firefox 15.0, OS X 10.7 (Lion)
+- Opera 12.01, OS X 10.7 (Lion)
Maybe other browser can be used. But I don't test these browsers.
diff --git a/grunt.js b/grunt.js
new file mode 100644
index 0000000..7fc5e55
--- /dev/null
+++ b/grunt.js
@@ -0,0 +1,68 @@
+/*global module:false*/
+module.exports = function(grunt) {
+
+ // Project configuration.
+ grunt.initConfig({
+ pkg: '<json:package.json>',
+ meta: {
+ banner: '/*! <%= pkg.title || pkg.name %>.js - v<%= pkg.version %> - ' +
+ '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
+ '<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' +
+ '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
+ ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'
+ },
+ lint: {
+ files: ['grunt.js', 'lib/**/*.js', '*.js']
+ },
+ buster: {
+ test: {
+ config: './test/buster.js'
+ }
+ },
+ concat: {
+ dist: {
+ src: ['<banner:meta.banner>', '<file_strip_banner:lib/<%= pkg.name %>.js>'],
+ dest: '<%= pkg.name %>.js'
+ }
+ },
+ min: {
+ dist: {
+ src: ['<banner:meta.banner>', '<config:concat.dist.dest>'],
+ dest: '<%= pkg.name %>.min.js'
+ }
+ },
+ watch: {
+ files: '<config:lint.files>',
+ tasks: 'buster'
+ },
+ jshint: {
+ options: {
+ curly: true,
+ eqeqeq: true,
+ immed: true,
+ latedef: true,
+ newcap: true,
+ noarg: true,
+ sub: true,
+ undef: true,
+ boss: true,
+ eqnull: true,
+ browser: true
+ },
+ globals: {
+ browser: true,
+ devel: true
+ }
+ },
+ uglify: {}
+ });
+
+ // Default task.
+ grunt.registerTask('default', 'concat min');
+
+ // Develop task.
+ grunt.registerTask('develop', 'buster');
+
+ // load grunt-buster
+ grunt.loadNpmTasks('grunt-buster');
+};
diff --git a/lib/rockstage.js b/lib/rockstage.js
index 8c2788f..0696818 100644
--- a/lib/rockstage.js
+++ b/lib/rockstage.js
@@ -1,62 +1,23 @@
-// Copyright (c) 2012 HIRAKI Satoru, https://github.com/Layzie
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
/**
* @fileOverView The library of 'localStorage' and 'sessionStorage'
* @author HIRAKI Satoru@Layzie
- * @version 0.0.3.6
+ * @version 0.0.5
*/
(function(window, undefined) {
'use strict';
-
/**
- * This function is called when 'RS' will be loaded. Then check the storageprivate
- * and set 'RS' name space in 'window'. (This is private)
+ * This function check the type. (This is private)
* @private
- * @return {Void} Return nothing
+ * @param {String} type String which you want to check type.
+ * @param argument Any type want to compare to type.
+ * @return {Boolean} Return type and argument is equal then return true.
*/
- (function _init() {
- if (window.localStorage && window.sessionStorage) {
- if (_checkArgument('Undefined', window.RS)) {
- window.RS = {};
- }
+ function _checkArgument(type, argument) {
+ var object = Object.prototype.toString.call(argument).slice(8, -1);
- /**
- * @namespace RS This library's namespace is 'RS'
- */
- window.RS = {
- put: put,
- get: get,
- remove: remove,
- clear: clear,
- is: is
- };
- } else {
- /**
- * @throws {Error} If a browser have no storage.
- */
- throw new Error('RS: This browser have no storage.');
- }
- })();
+ return argument !== undefined && argument !== null && object === type;
+ }
/**
* This function is select the storage. True or undefined is
@@ -67,32 +28,22 @@
* @return {Object} Return localStorage or sessionStorage.
*/
function _selectStorage(flag, fun) {
- var storage;
+ var order = (fun !== 'clear()') ? '2nd ' : '',
+ storage;
if (_checkArgument('Boolean', flag) || flag === undefined) {
- return storage = (flag === true || flag === undefined) ? localStorage : sessionStorage;
+ storage = (flag === true || flag === undefined) ? localStorage : sessionStorage;
+
+ return storage;
} else {
/**
- * @throws {Error} If second argument isn't boolean.
+ * @throws {Error} If second argument(only argyment in RS.clear()) isn't boolean.
*/
- throw new Error('RS.' + fun + ': 2nd argument should be boolean');
+ throw new Error('RS.' + fun + ': ' + order + 'argument should be boolean');
}
}
/**
- * This function check the type. (This is private)
- * @private
- * @param {String} type String which you want to check type.
- * @param argument Any type want to compare to type.
- * @return {Boolean} Return type and argument is equal then return true.
- */
- function _checkArgument(type, argument) {
- var object = Object.prototype.toString.call(argument).slice(8, -1);
-
- return argument !== undefined && argument !== null && object === type;
- }
-
- /**
* You can set object into the storage.
* @param {Object} obj Object which you want to save the storage.
* @param {Boolean} flag Boolean which the storage you want to use. Default is 'true'.
@@ -202,5 +153,49 @@
throw new Error('RS.is(): 1st argument should be strings');
}
}
-})(this);
+
+ /**
+ * You can check existance of a object in the storage.
+ * @param {Boolean} flag Boolean which the storage you want to use. Default is 'true'.
+ * @return {Number} Return object's length in storage
+ * @example When you'll check object's length in localStorage.
+ * RS.length();
+ */
+ function length(flag) {
+ var storage = _selectStorage(flag, 'length()');
+
+ return storage.length;
+ }
+
+ /**
+ * This function is called when 'RS' will be loaded. Then check the storageprivate
+ * and set 'RS' name space in 'window'. (This is private)
+ * @private
+ * @return {Void} Return nothing
+ */
+ (function _init() {
+ if (window.localStorage && window.sessionStorage) {
+ if (_checkArgument('Undefined', window.RS)) {
+ window.RS = {};
+ }
+
+ /**
+ * @namespace RS This library's namespace is 'RS'
+ */
+ window.RS = {
+ put: put,
+ get: get,
+ remove: remove,
+ clear: clear,
+ is: is,
+ length: length
+ };
+ } else {
+ /**
+ * @throws {Error} If a browser have no storage.
+ */
+ throw new Error('RS: This browser have no storage.');
+ }
+ }());
+}(this));
diff --git a/makefile b/makefile
deleted file mode 100644
index d8fb80f..0000000
--- a/makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-all: compress
-
-compress:
- uglifyjs --output ./rockstage.min.js lib/rockstage.js; cp lib/rockstage.js ./rockstage.js
-
-clean:
- rm ./rockstage.js ./rockstage.min.js
-
-.PHONY: Rockstage.js is compressed.
-
diff --git a/package.json b/package.json
index 35a7768..1b92439 100644
--- a/package.json
+++ b/package.json
@@ -1,15 +1,44 @@
{
- "author" : "Layzie",
- "name" : "rockstage.js",
- "description" : "The JavaScript library for using 'localStorage' & 'sessionStorage' more easy",
- "version" : "0.0.3.6",
- "scripts" : {
- "test" : "node_modules/.bin/buster-test"
- },
- "dependencies" : {
- "buster" : "~0.6"
- },
- "engines" : {
- "node" : "~0.8"
- }
+ "author": {
+ "name": "HIRAKI Satoru",
+ "email": "[email protected]",
+ "url": "http://layzie.hatenablog.com/"
+ },
+ "name": "rockstage",
+ "description": "The JavaScript library for using 'localStorage' & 'sessionStorage' more easy",
+ "version" : "0.0.5",
+ "scripts": {
+ "test": "node_modules/.bin/buster-test"
+ },
+ "dependencies": {
+ "buster": "~0.6.3"
+ },
+ "devDependencies": {
+ "buster": "~0.6.3",
+ "grunt": "~0.3.17",
+ "grunt-buster": "~0.1.2"
+ },
+ "engines": {
+ "node": "~0.8"
+ },
+ "main": "./lib/rockstage.js",
+ "directories": {
+ "test": "test"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/Layzie/rockstage_js.git"
+ },
+ "keywords": [
+ "Localstorage",
+ "html5",
+ "javascript"
+ ],
+ "homepage": "http://layzie.github.com/rockstage_js",
+ "licenses": [
+ {
+ "type": "MIT",
+ "url": "https://github.com/Layzie/rockstage_js/blob/master/LICENCE"
+ }
+ ]
}
diff --git a/rockstage.js b/rockstage.js
index 8c2788f..ce08a85 100644
--- a/rockstage.js
+++ b/rockstage.js
@@ -1,62 +1,21 @@
-// Copyright (c) 2012 HIRAKI Satoru, https://github.com/Layzie
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-/**
- * @fileOverView The library of 'localStorage' and 'sessionStorage'
- * @author HIRAKI Satoru@Layzie
- * @version 0.0.3.6
- */
+/*! rockstage.js - v0.0.5 - 2012-12-14
+* http://layzie.github.com/rockstage_js
+* Copyright (c) 2012 HIRAKI Satoru; Licensed MIT */
(function(window, undefined) {
'use strict';
-
/**
- * This function is called when 'RS' will be loaded. Then check the storageprivate
- * and set 'RS' name space in 'window'. (This is private)
+ * This function check the type. (This is private)
* @private
- * @return {Void} Return nothing
+ * @param {String} type String which you want to check type.
+ * @param argument Any type want to compare to type.
+ * @return {Boolean} Return type and argument is equal then return true.
*/
- (function _init() {
- if (window.localStorage && window.sessionStorage) {
- if (_checkArgument('Undefined', window.RS)) {
- window.RS = {};
- }
+ function _checkArgument(type, argument) {
+ var object = Object.prototype.toString.call(argument).slice(8, -1);
- /**
- * @namespace RS This library's namespace is 'RS'
- */
- window.RS = {
- put: put,
- get: get,
- remove: remove,
- clear: clear,
- is: is
- };
- } else {
- /**
- * @throws {Error} If a browser have no storage.
- */
- throw new Error('RS: This browser have no storage.');
- }
- })();
+ return argument !== undefined && argument !== null && object === type;
+ }
/**
* This function is select the storage. True or undefined is
@@ -67,32 +26,22 @@
* @return {Object} Return localStorage or sessionStorage.
*/
function _selectStorage(flag, fun) {
- var storage;
+ var order = (fun !== 'clear()') ? '2nd ' : '',
+ storage;
if (_checkArgument('Boolean', flag) || flag === undefined) {
- return storage = (flag === true || flag === undefined) ? localStorage : sessionStorage;
+ storage = (flag === true || flag === undefined) ? localStorage : sessionStorage;
+
+ return storage;
} else {
/**
- * @throws {Error} If second argument isn't boolean.
+ * @throws {Error} If second argument(only argyment in RS.clear()) isn't boolean.
*/
- throw new Error('RS.' + fun + ': 2nd argument should be boolean');
+ throw new Error('RS.' + fun + ': ' + order + 'argument should be boolean');
}
}
/**
- * This function check the type. (This is private)
- * @private
- * @param {String} type String which you want to check type.
- * @param argument Any type want to compare to type.
- * @return {Boolean} Return type and argument is equal then return true.
- */
- function _checkArgument(type, argument) {
- var object = Object.prototype.toString.call(argument).slice(8, -1);
-
- return argument !== undefined && argument !== null && object === type;
- }
-
- /**
* You can set object into the storage.
* @param {Object} obj Object which you want to save the storage.
* @param {Boolean} flag Boolean which the storage you want to use. Default is 'true'.
@@ -202,5 +151,49 @@
throw new Error('RS.is(): 1st argument should be strings');
}
}
-})(this);
+
+ /**
+ * You can check existance of a object in the storage.
+ * @param {Boolean} flag Boolean which the storage you want to use. Default is 'true'.
+ * @return {Number} Return object's length in storage
+ * @example When you'll check object's length in localStorage.
+ * RS.length();
+ */
+ function length(flag) {
+ var storage = _selectStorage(flag, 'length()');
+
+ return storage.length;
+ }
+
+ /**
+ * This function is called when 'RS' will be loaded. Then check the storageprivate
+ * and set 'RS' name space in 'window'. (This is private)
+ * @private
+ * @return {Void} Return nothing
+ */
+ (function _init() {
+ if (window.localStorage && window.sessionStorage) {
+ if (_checkArgument('Undefined', window.RS)) {
+ window.RS = {};
+ }
+
+ /**
+ * @namespace RS This library's namespace is 'RS'
+ */
+ window.RS = {
+ put: put,
+ get: get,
+ remove: remove,
+ clear: clear,
+ is: is,
+ length: length
+ };
+ } else {
+ /**
+ * @throws {Error} If a browser have no storage.
+ */
+ throw new Error('RS: This browser have no storage.');
+ }
+ }());
+}(this));
diff --git a/rockstage.min.js b/rockstage.min.js
index 9ea35e6..6e2d731 100644
--- a/rockstage.min.js
+++ b/rockstage.min.js
@@ -1,25 +1,4 @@
-// Copyright (c) 2012 HIRAKI Satoru, https://github.com/Layzie
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-/**
- * @fileOverView The library of 'localStorage' and 'sessionStorage'
- * @author HIRAKI Satoru@Layzie
- * @version 0.0.3.6
- */(function(e,t){"use strict";function n(e,n){var i;if(r("Boolean",e)||e===t)return i=e===!0||e===t?localStorage:sessionStorage;throw new Error("RS."+n+": 2nd argument should be boolean")}function r(e,n){var r=Object.prototype.toString.call(n).slice(8,-1);return n!==t&&n!==null&&r===e}function i(e,t){var i=n(t,"put()");if(!r("Object",e)||!!r("Array",e))throw new Error("RS.put(): 1st argument should be object");for(var s in e)e.hasOwnProperty(s)&&i.setItem(s,JSON.stringify(e[s]))}function s(e,t){var i=n(t,"get()"),s=i.getItem(e);if(r("String",e))return s?JSON.parse(s):console.log("RS.get(): This key is not in storage");throw new Error("RS.get(): 1st argument should be string")}function o(e,t){var i=n(t,"remove()"),s=i.getItem(e);r("String",e)&&(s?i.removeItem(e):console.log("RS.remove(): This key is not in storage"))}function u(e){var t=n(e,"clear()");t.clear()}function a(e,t){var i=n(t,"is()"),s=i.getItem(e);if(r("String",e))return s?!0:!1;throw new Error("RS.is(): 1st argument should be strings")}(function(){if(!e.localStorage||!e.sessionStorage)throw new Error("RS: This browser have no storage.");r("Undefined",e.RS)&&(e.RS={}),e.RS={put:i,get:s,remove:o,clear:u,is:a}})()})(this);
\ No newline at end of file
+/*! rockstage.js - v0.0.5 - 2012-12-14
+* http://layzie.github.com/rockstage_js
+* Copyright (c) 2012 HIRAKI Satoru; Licensed MIT */
+(function(e,t){"use strict";function n(e,n){var r=Object.prototype.toString.call(n).slice(8,-1);return n!==t&&n!==null&&r===e}function r(e,r){var i=r!=="clear()"?"2nd ":"",s;if(n("Boolean",e)||e===t)return s=e===!0||e===t?localStorage:sessionStorage,s;throw new Error("RS."+r+": "+i+"argument should be boolean")}function i(e,t){var i=r(t,"put()");if(!n("Object",e)||!!n("Array",e))throw new Error("RS.put(): 1st argument should be object");for(var s in e)e.hasOwnProperty(s)&&i.setItem(s,JSON.stringify(e[s]))}function s(e,t){var i=r(t,"get()"),s=i.getItem(e);if(n("String",e))return s?JSON.parse(s):console.log("RS.get(): This key is not in storage");throw new Error("RS.get(): 1st argument should be string")}function o(e,t){var i=r(t,"remove()"),s=i.getItem(e);n("String",e)&&(s?i.removeItem(e):console.log("RS.remove(): This key is not in storage"))}function u(e){var t=r(e,"clear()");t.clear()}function a(e,t){var i=r(t,"is()"),s=i.getItem(e);if(n("String",e))return s?!0:!1;throw new Error("RS.is(): 1st argument should be strings")}function f(e){var t=r(e,"length()");return t.length}(function(){if(!e.localStorage||!e.sessionStorage)throw new Error("RS: This browser have no storage.");n("Undefined",e.RS)&&(e.RS={}),e.RS={put:i,get:s,remove:o,clear:u,is:a,length:f}})()})(this);
\ No newline at end of file
diff --git a/test/buster.js b/test/buster.js
index c9ff24d..ba5e21f 100644
--- a/test/buster.js
+++ b/test/buster.js
@@ -3,6 +3,6 @@ var config = module.exports;
config['RockstageTest'] = {
env: 'browser',
rootPath: '../',
- src: ['lib/rockstage.js', 'rockstage.min.js'],
+ src: ['lib/rockstage.js'],
tests: ['test/*-test.js']
};
diff --git a/test/rockstage-exception-test.js b/test/rockstage-exception-test.js
index 6077934..89c480a 100644
--- a/test/rockstage-exception-test.js
+++ b/test/rockstage-exception-test.js
@@ -25,7 +25,7 @@ buster.testCase('RockstageExceptionTest', {
try {
RS.clear(function() {});
} catch(e) {
- assert.same(e.message, 'RS.clear(): 2nd argument should be boolean');
+ assert.same(e.message, 'RS.clear(): argument should be boolean');
}
},
'RS should be called when browser have storage': function() {
diff --git a/test/rockstage-storage-test.js b/test/rockstage-storage-test.js
index 4edba0c..4f85563 100644
--- a/test/rockstage-storage-test.js
+++ b/test/rockstage-storage-test.js
@@ -30,7 +30,7 @@ buster.testCase('RockstageStorageTest', {
refute.equals(null, RS.remove('bar', true));
refute.equals(null, RS.remove('bar'));
},
- 'RS.clear() should be chosen localStorage by 2nd argument is true or undefined': function() {
+ 'RS.clear() should be chosen localStorage by argument is true or undefined': function() {
var lStorage = localStorage.setItem('foo', JSON.stringify('hoge'));
var sStorage = sessionStorage.setItem('bar', JSON.stringify('fuga'));
@@ -68,7 +68,7 @@ buster.testCase('RockstageStorageTest', {
assert.equals(undefined, RS.remove('bar', false));
refute.equals(null, RS.remove('foo', false));
},
- 'RS.clear() should be chosen localStorage by 2nd argument is true or undefined': function() {
+ 'RS.clear() should be chosen localStorage by argument is true or undefined': function() {
var lStorage = localStorage.setItem('foo', JSON.stringify('hoge'));
var sStorage = sessionStorage.setItem('bar', JSON.stringify('fuga'));
diff --git a/test/rockstage-test.js b/test/rockstage-test.js
index 90d3712..18e47c8 100644
--- a/test/rockstage-test.js
+++ b/test/rockstage-test.js
@@ -42,5 +42,10 @@ buster.testCase('RockstageTest', {
assert.isTrue(RS.is('bar'));
assert.isTrue(RS.is('baz'));
assert.isFalse(RS.is('storage'));
+ },
+ 'length should be returned object\'s length in storage': function() {
+ RS.put({foo: 'hoge', bar: 'fuga', baz: 'hogera'});
+
+ assert.equals(3, RS.length());
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment