Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Change syntax a little bit, remove only .parse-method

  • Loading branch information...
commit f053b6ffac5948dcea31dce3ab82d618d4a89f5c 1 parent ef16311
David Björklund authored

Showing 3 changed files with 6 additions and 7 deletions. Show diff stats Hide diff stats

  1. +1 1  Readme.md
  2. +4 4 lib/css2json.js
  3. +1 2  test/all.js
2  Readme.md
Source Rendered
@@ -12,7 +12,7 @@ npm install css2json
12 12
13 13 ```
14 14 var css2json = require('css2json');
15   -var json = css2json.parse(css);
  15 +var json = css2json(css);
16 16 ```
17 17
18 18 ## Example
8 lib/css2json.js
@@ -3,14 +3,14 @@
3 3 // css2json is a <a href="http://www.opensource.org/licenses/mit-license.php">open source</a>
4 4 // library for <a href="http://nodejs.org">Node.js</a> (with browser
5 5 // compability planned) hosted on <a href="https://github.com/kesla/css2json">github</a>
6   -// and written by <a href="http://davidbjorklund.se">David Björklund</a>.
  6 +// and written by <a href="http://davidbjorklund.se">David Björklund</a>.
7 7
8 8 // Require <a href="http://documentcloud.github.com/underscore/">underscore</a>
9 9 // for some utilities and browser support.
10 10 var _ = require('underscore');
11 11
12   -// Main (only) method that parses a string with css to a json-object.
13   -exports.parse = parse = function(css) {
  12 +// Parse a string with css to a json-object.
  13 +module.exports = function(css) {
14 14
15 15 // Remove all comments from the css-file
16 16 while((open = css.indexOf("/*")) !== -1 &&
@@ -58,7 +58,7 @@ exports.parse = parse = function(css) {
58 58
59 59 // Remove any empty ("") values from the array
60 60 declarations = _.compact(declarations);
61   -
  61 +
62 62 // _declaration_ is now an array reado to be transformed into an object.
63 63 declarations = toObject(declarations);
64 64
3  test/all.js
@@ -11,6 +11,5 @@ bases.forEach(function(base){
11 11 var css = fs.readFileSync(basePath + '.css', 'utf8'),
12 12 json = JSON2.parse(fs.readFileSync(basePath + '.json', 'utf8'));
13 13
14   - assert.deepEqual(css2json.parse(css), json);
15   -
  14 + assert.deepEqual(css2json(css), json);
16 15 });

0 comments on commit f053b6f

Please sign in to comment.
Something went wrong with that request. Please try again.