Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit f053b6ffac5948dcea31dce3ab82d618d4a89f5c 1 parent ef16311
David Björklund authored
Showing with 6 additions and 7 deletions.
  1. +1 −1  Readme.md
  2. +4 −4 lib/css2json.js
  3. +1 −2  test/all.js
2  Readme.md
View
@@ -12,7 +12,7 @@ npm install css2json
```
var css2json = require('css2json');
-var json = css2json.parse(css);
+var json = css2json(css);
```
## Example
8 lib/css2json.js
View
@@ -3,14 +3,14 @@
// css2json is a <a href="http://www.opensource.org/licenses/mit-license.php">open source</a>
// library for <a href="http://nodejs.org">Node.js</a> (with browser
// compability planned) hosted on <a href="https://github.com/kesla/css2json">github</a>
-// and written by <a href="http://davidbjorklund.se">David Björklund</a>.
+// and written by <a href="http://davidbjorklund.se">David Björklund</a>.
// Require <a href="http://documentcloud.github.com/underscore/">underscore</a>
// for some utilities and browser support.
var _ = require('underscore');
-// Main (only) method that parses a string with css to a json-object.
-exports.parse = parse = function(css) {
+// Parse a string with css to a json-object.
+module.exports = function(css) {
// Remove all comments from the css-file
while((open = css.indexOf("/*")) !== -1 &&
@@ -58,7 +58,7 @@ exports.parse = parse = function(css) {
// Remove any empty ("") values from the array
declarations = _.compact(declarations);
-
+
// _declaration_ is now an array reado to be transformed into an object.
declarations = toObject(declarations);
3  test/all.js
View
@@ -11,6 +11,5 @@ bases.forEach(function(base){
var css = fs.readFileSync(basePath + '.css', 'utf8'),
json = JSON2.parse(fs.readFileSync(basePath + '.json', 'utf8'));
- assert.deepEqual(css2json.parse(css), json);
-
+ assert.deepEqual(css2json(css), json);
});
Please sign in to comment.
Something went wrong with that request. Please try again.