Permalink
Browse files

README

  • Loading branch information...
hadashiA committed Nov 7, 2012
1 parent 40ee6ff commit 35ca00f7c9167dde743ff5ffac8e1425726b81c6
Showing with 42 additions and 13 deletions.
  1. +42 −13 README.md
View
@@ -11,29 +11,58 @@ var sexpression = require('sexpression');
```
```javascript
-sexpression.parse('()') //=> null
-sexpression.parse('(1 -2 3.45)') //=> [1, -2, 3.45]
-sexpression.parse('(a b c)') //=> [{ name: 'a' }, { name: 'b' }, { name: 'c' }]
-sexpression.parse('(a b (1 2) "a")') //=> [{ name: 'a' }, { name: 'b' }, [1, 2], 'a']
+sexpression.parse('()')
+//=> null
+
+sexpression.parse('(1 -2 3.45)')
+//=> [1, -2, 3.45]
+
+sexpression.parse('(a b c)')
+//=> [{ name: 'a' }, { name: 'b' }, { name: 'c' }]
+
+sexpression.parse('(a b (1 2) "a")')
+//=> [{ name: 'a' }, { name: 'b' }, [1, 2], 'a']
+
+sexpression.parse('(:hoge 1 :fuga 2)')
+//=> { hoge: 1, fuga: 2 }
+
+sexpression.parse('(a b :hoge 1 :fuga 2 c)')
+//=> [{ name: 'a' }, { name: 'b'}, { hoge: 1, fuga: 2 }, { name: c }]
sexpression.parse('(1 . 2)')
//=> { car: 1, cdr: 2 }
+
sexpression.parse('((hoge . 1) (fuga . 2))')
//=> [{ car: { name: 'hoge'}, cdr: 1}, { car: { name: 'fuga' }, cdr: 2 }]
```
```javascript
-sexpression.stringify([]); //=> 'nil'
-sexpression.stringify([1, -2, 3.45]) //=> '(1 -2 3.45)'
-sexpression.stringify([{ name: 'a' }, { name: 'b' }, [1, 2], 'a']) //=> '(a b (1 2) "a")'
+sexpression.stringify([]);
+//=> 'nil'
+
+sexpression.stringify([1, -2, 3.45])
+//=> '(1 -2 3.45)'
+
+sexpression.stringify([{ name: 'a' }, { name: 'b' }, [1, 2], 'a'])
+//=> '(a b (1 2) "a")'
+
+sexpression.stringify({ car: 1, cdr: 2})
+//=> '(1 . 2)'
+
+sexpression.stringify([{ car: { name: 'hoge'}, cdr: 1}, { car: { name: 'fuga' }, cdr: 2 }])
+//=> '((hoge . 1) (fuga . 2))'
+
+sexpression.stringify({ a: 1, b: 2})
+//=> '(:a 1 :b 2)'
+
+sexpression.stringify([1, { hoge: 1, fuga: 2 }, "aaa"])
+//=> '(1 (:hoge 1 :fuga 2) "aaa")'
-sexpression.stringify({ car: 1, cdr: 2}) //=> '(1 . 2)'
-sexpression.stringify([{ car: { name: 'hoge'}, cdr: 1}, { car: { name: 'fuga' }, cdr: 2 }]) //=> '((hoge . 1) (fuga . 2))'
+sexpression.stringify({ a: 1, b: 2}, 'alist')
+//=> '(("a" . 1) ("b" . 2))'
-sexpression.stringify({ a: 1, b: 2}) //=> '(:a 1 :b 2)'
-sexpression.stringify([1, { hoge: 1, fuga: 2 }, "aaa"]) //=> '(1 (:hoge 1 :fuga 2) "aaa")'
-sexpression.stringify({ a: 1, b: 2}, 'alist) //=> '(("a" . 1) ("b" . 2))'
-sexpression.stringify([1, { hoge: 1, fuga: 2 }, "aaa"], 'alist) //=> '(1 (('hoge' . 1) ('fuga' . 2)) 'aaa')'
+sexpression.stringify([1, { hoge: 1, fuga: 2 }, "aaa"], 'alist')
+//=> '(1 (('hoge' . 1) ('fuga' . 2)) 'aaa')'
```

0 comments on commit 35ca00f

Please sign in to comment.