Permalink
Browse files

Updated BufferedWriter, added test

  • Loading branch information...
Gabriel Llamas
Gabriel Llamas committed May 4, 2012
1 parent b557f99 commit 9d4da3c403ac61ac46bdd4f5c2b986a1dabfb33f
View
@@ -1,3 +1,6 @@
+Characters that cannot be directly represented in ISO 8859-1 encoding can be
+written using Unicode escapes.
+
Properties are processed in terms of lines. There are two kinds of line,
natural lines and logical lines. A natural line is defined as a line of
characters that is terminated either by a set of line terminator characters
@@ -95,4 +98,4 @@ sequences and Unicode escapes used for characters and strings are:
- Escapes are not necessary for single and double quotes; however, by the
rule above, single and double quote characters preceded by a backslash
still yield single and double quote characters, respectively.
- - Only a single 'u' character is allowed in a Uniocde escape sequence.
+ - Only a single 'u' character is allowed in a Unicode escape sequence.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -0,0 +1,6 @@
+var Properties = require ("../build/properties");
+
+new Properties ()
+ .set ("", "")
+ .set ("", "")
+ .store ("tmp", true)
View
@@ -5,12 +5,8 @@ new Properties ()
.set ("p2", null, "Property 2, empty")
.set ("p3", "v3")
.set ("p4", null)
- .store ("example.properties", "Example .properties file", function (error, stored){
- console.log ("stored: " + stored);
-
- new Properties ().load ("example.properties", function (error, loaded){
- console.log ("loaded: " + loaded);
-
+ .store ("example.properties", "Example .properties file", function (error){
+ new Properties ().load ("example.properties", function (error){
var me = this;
var keys = this.keys ();
console.log ("keys: " + keys);
View
@@ -218,12 +218,12 @@ Properties.prototype.load = function (fileName, cb){
value: value
}
}, function (){
- if (cb) cb (null, true);
+ if (cb) cb (null);
});
new BufferedReader (fileName, { encoding: "utf8" })
.on ("error", function (error){
- if (cb) cb (error, false);
+ if (cb) cb (error);
})
.on ("character", function (character){
pr.parse (character);
@@ -334,7 +334,7 @@ Properties.prototype.store = function (fileName, unicode, headerComment, cb){
if (cb) cb = cb.bind (this);
var bw = new BufferedWriter (fileName, { encoding: "utf8" });
bw.on ("error", function (error){
- if (cb) cb (error, false);
+ if (cb) cb (error);
});
if (headerComment){
@@ -351,9 +351,9 @@ Properties.prototype.store = function (fileName, unicode, headerComment, cb){
convert (k.value, false, unicode)).newLine ();
}
- bw.close ();
-
- if (cb) cb (null, true);
+ bw.close (function (){
+ if (cb) cb (null);
+ });
};
module.exports = Properties;
View
@@ -1 +1 @@
-var Properties = require ("../build/properties").Properties;
+var Properties = require ("../build/properties");
@@ -1,5 +1,5 @@
+var Properties = require ("../../build/properties");
var assert = require ("assert");
-var Properties = require ("../build/properties").Properties;
var o = {
a1: { value: "b" },
@@ -16,10 +16,11 @@ var o = {
empty: { value: "" },
empty2: { value: "" },
"É": { value: "É" },
- E_unicode: { value: "É" }
+ "": { value: "" },
+ E_unicode: { value: "É" },
+ "": { value: "" }
};
-var properties = new Properties ();
-properties.load ("test", function (error, loaded){
- assert.deepEqual (properties._keys, o);
+new Properties ().load ("test", function (error){
+ assert.deepEqual (this._keys, o);
});
@@ -0,0 +1,8 @@
+var Properties = require ("../../build/properties");
+
+new Properties ()
+ .set ("", "")
+ .set ("", "")
+ .store ("tmp", function (error){
+ if (error) console.log (error);
+ });
@@ -32,5 +32,7 @@ empty2
#Unicode
É : É
+↑ ↓
!Escaped unicode
-E_unicode \u00C9
+E_unicode \u00C9
+\u2190=\u2192

0 comments on commit 9d4da3c

Please sign in to comment.