Permalink
Browse files

Stop depend on underscore

  • Loading branch information...
1 parent f053b6f commit 04849a169329a3092d5eac685ac434dbb0c7a765 @kesla committed Jun 21, 2012
Showing with 8 additions and 12 deletions.
  1. +8 −9 lib/css2json.js
  2. +0 −3 package.json
View
17 lib/css2json.js
@@ -5,10 +5,6 @@
// 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>.
-// Require <a href="http://documentcloud.github.com/underscore/">underscore</a>
-// for some utilities and browser support.
-var _ = require('underscore');
-
// Parse a string with css to a json-object.
module.exports = function(css) {
@@ -54,10 +50,10 @@ module.exports = function(css) {
.split(";")
.map(function(declaration){
return declaration.trim();
- });
-
- // Remove any empty ("") values from the array
- declarations = _.compact(declarations);
+ })
+ .filter(function(declaration) {
+ return declaration.length > 0;
+ }); // Remove any empty ("") values from the array
// _declaration_ is now an array reado to be transformed into an object.
declarations = toObject(declarations);
@@ -84,7 +80,10 @@ module.exports = function(css) {
// _selector_.
if (!json[selector]) json[selector] = {};
// Save the declarations to the right selector
- _.extend(json[selector], declarations);
+
+ Object.keys(declarations).forEach(function(key) {
+ json[selector][key] = declarations[key];
+ });
});
// Continue to next instance
css = css.slice(rbracket + 1).trim()
View
3 package.json
@@ -11,9 +11,6 @@
"engines": {
"node": "*"
},
- "dependencies": {
- "underscore": "~1.1.7"
- },
"devDependencies": {
"json-san": "0.0.2"
}

0 comments on commit 04849a1

Please sign in to comment.