Compare commits

..

18 Commits

Author SHA1 Message Date
AJ ONeal
3acf6a0abf New location (self-hosted) 2017-01-07 13:25:29 -07:00
AJ ONeal
c532da6cca Update README.md 2016-11-25 11:07:15 -07:00
AJ ONeal
0d914a3661 moved 2014-05-20 09:13:38 -06:00
AJ ONeal
001cf59083 point to new repo 2014-05-20 09:03:48 -06:00
AJ ONeal
7294e5e787 Update README.md 2014-05-20 10:01:19 -05:00
AJ ONeal
b69db22284 Update README.md 2014-05-20 10:00:53 -05:00
9807dbedc6 verbump 2013-07-25 09:15:01 -07:00
8b15697a10 convert non-buffer objects first to strings 2013-07-25 09:14:17 -07:00
07082fdb4e fixed typo in readme 2013-07-25 09:13:49 -07:00
0f12759eb8 Merge pull request #4 from zbjornson/zbpatch1
Call toString on args to match browser behavior.
2013-07-25 09:05:45 -07:00
Zach Bjornson
c391d903e3 Call toString on args to match browser behavior. 2013-07-20 09:22:32 -07:00
c1673f281c handle actual binary, not just utf8 2012-09-19 14:22:55 -06:00
ba6a6282f1 Merge pull request #3 from pwnall/patch-2
Fix atob to match browser implementations
2012-09-19 12:56:09 -07:00
d86a3f5fc3 Merge pull request #2 from pwnall/patch-1
Fix btoa to match browser implementations
2012-09-19 12:55:58 -07:00
Victor Costan
00b5c14843 Fix atob to match browser implementations
Test case:
atob('/A==') === String.fromCharCode(252) should be true
2012-09-13 02:15:36 -03:00
Victor Costan
133496cd12 Fix btoa to match browser implementations
Test case:
btoa(String.fromCharCode(252)) should return "/A=="
2012-09-13 02:08:20 -03:00
48288ef240 added cli tool 2012-06-26 13:28:01 -06:00
30c4163ba8 added cli bin 2012-06-26 13:24:09 -06:00
13 changed files with 13 additions and 248 deletions

View File

@ -1,5 +1,2 @@
Goals
===
* reserve the names of W3C modules ('geolocation', 'locacStorage', etc) on npm
* implement W3C modules for node
# Moved
### [node-browser-compat](https://git.daplie.com/coolaj86/node-browser-compat) is now at [git.daplie.com/coolaj86/node-browser-compat](https://git.daplie.com/coolaj86/node-browser-compat)

4
atob/README.md Normal file
View File

@ -0,0 +1,4 @@
MOVED
====
Now at https://github.com/node-browser-compat/atob

View File

@ -1,9 +0,0 @@
(function () {
"use strict";
function atob(str) {
return new Buffer(str, 'base64').toString('utf8');
}
module.exports = atob;
}());

View File

@ -1,18 +0,0 @@
{
"name" : "atob",
"homepage" : "https://github.com/coolaj86/node-browser-compat",
"description" : "atob for Node.JS (it's a one-liner)",
"repository" : {
"type": "git",
"url": "git://github.com/coolaj86/node-browser-compat.git"
},
"keywords" : ["atob", "browser"],
"author" : "AJ ONeal <coolaj86@gmail.com> (http://coolaj86.info)",
"engines" : {
"node": ">= 0.4.0"
},
"dependencies" : {
},
"main" : "index",
"version" : "1.0.0"
}

View File

@ -1,15 +0,0 @@
(function () {
"use strict";
var atob = require('./index')
, encoded = "SGVsbG8gV29ybGQ="
, unencoded = "Hello World"
, result
;
if (unencoded !== atob(encoded)) {
return;
}
console.log('[PASS] all tests pass');
}());

4
btoa/README.md Normal file
View File

@ -0,0 +1,4 @@
MOVED
====
Now at https://github.com/node-browser-compat/btoa

View File

@ -1,9 +0,0 @@
(function () {
"use strict";
function btoa(str) {
return new Buffer(str, 'utf8').toString('base64');
}
module.exports = btoa;
}());

View File

@ -1,18 +0,0 @@
{
"name" : "btoa",
"homepage" : "https://github.com/coolaj86/node-browser-compat",
"description" : "btoa for Node.JS (it's a one-liner)",
"repository" : {
"type": "git",
"url": "git://github.com/coolaj86/node-browser-compat.git"
},
"keywords" : ["btoa", "browser"],
"author" : "AJ ONeal <coolaj86@gmail.com> (http://coolaj86.info)",
"engines" : {
"node": ">= 0.4.0"
},
"dependencies" : {
},
"main" : "index",
"version" : "1.0.0"
}

View File

@ -1,15 +0,0 @@
(function () {
"use strict";
var btoa = require('./index')
, encoded = "SGVsbG8gV29ybGQ="
, unencoded = "Hello World"
, result
;
if (encoded !== btoa(unencoded)) {
return;
}
console.log('[PASS] all tests pass');
}());

View File

@ -1,56 +1,4 @@
localStorage
===
MOVED
=====
An inefficient, but as W3C-compliant as possible using only pure JavaScript, `localStorage` implementation.
Purpose
----
This is meant for the purpose of being able to run unit-tests and such for browser-y modules in node.
Usage
----
var localStorage = require('localStorage')
, myValue = { foo: 'bar', baz: 'quux' }
;
localStorage.setItem('myKey', JSON.stringify(myValue));
myValue = localStorage.getItem('myKey');
API
---
* getItem(key)
* setItem(key, value)
* removeItem(key)
* clear()
* key(n)
* length
Tests
---
0 === localStorage.length;
null === localStorage.getItem('doesn't exist');
undefined === localStorage['doesn't exist'];
localStorage.setItem('myItem');
"undefined" === localStorage.getItem('myItem');
1 === localStorage.length;
localStorage.setItem('myItem', 0);
"0" === localStorage.getItem('myItem');
localStorage.removeItem('myItem', 0);
0 === localStorage.length;
localStorage.clear();
0 === localStorage.length;
TODO / Bugs
---
* Does not persist.
* could use `fs.readFileSync` at load and an occasional `fs.writeFile` to write-out localStorage.json
* Doesn't not emit `Storage` events
Now at https://github.com/node-browser-compat/dom-storage

View File

@ -1,54 +0,0 @@
// http://www.rajdeepd.com/articles/chrome/localstrg/LocalStorageSample.htm
// NOTE:
// this varies from actual localStorage in some subtle ways
// also, there is no persistence
// TODO persist
(function () {
"use strict";
var db;
function LocalStorage() {
}
db = LocalStorage;
db.prototype.getItem = function (key) {
if (key in this) {
return String(this[key]);
}
return null;
};
db.prototype.setItem = function (key, val) {
this[key] = String(val);
};
db.prototype.removeItem = function (key) {
delete this[key];
};
db.prototype.clear = function () {
var self = this;
Object.keys(self).forEach(function (key) {
self[key] = undefined;
delete self[key];
});
};
db.prototype.key = function (i) {
i = i || 0;
return Object.keys(this)[i];
};
db.prototype.__defineGetter__('length', function () {
return Object.keys(this).length;
});
if (global.localStorage) {
module.exports = localStorage;
} else {
module.exports = new LocalStorage();
}
}());

View File

@ -1,16 +0,0 @@
{
"author": "AJ ONeal <coolaj86@gmail.com> (http://coolaj86.info)",
"name": "localStorage",
"description": "W3C localStorage for Node.JS",
"version": "1.0.0",
"repository": {
"type": "git",
"url": "git://github.com/coolaj86/node-localStorage.git"
},
"engines": {
"node": ">= v0.2.0"
},
"main": "localStorage.js",
"dependencies": {},
"devDependencies": {}
}

View File

@ -1,34 +0,0 @@
(function () {
"use strict";
var assert = require('assert')
, localStorage = require('localStorage')
;
// can't make assuptions about key positioning
localStorage.setItem('a', 1);
assert.strictEqual(localStorage.key(0), 'a');
localStorage.setItem('b', '2');
assert.strictEqual(localStorage.getItem('a'), '1');
assert.strictEqual(localStorage.getItem('b'), '2');
assert.strictEqual(localStorage.length, 2);
assert.strictEqual(localStorage['c'], undefined);
assert.strictEqual(localStorage.getItem('c'), null);
localStorage.setItem('c');
assert.strictEqual(localStorage.getItem('c'), "undefined");
assert.strictEqual(localStorage.length, 3);
localStorage.removeItem('c');
assert.strictEqual(localStorage.getItem('c'), null);
assert.strictEqual(localStorage.length, 2);
localStorage.clear();
assert.strictEqual(localStorage.getItem('a'), null);
assert.strictEqual(localStorage.getItem('b'), null);
assert.strictEqual(localStorage.length, 0);
console.log('All tests passed');
}());