webpack-isomorphic-tools
Advanced tools
Comparing version 0.8.5 to 0.8.6
@@ -14,2 +14,3 @@ // // if the variable is defined | ||
exports.clone = clone; | ||
exports.alias_camel_case = alias_camel_case; | ||
var exists = function exists(what) { | ||
@@ -91,2 +92,41 @@ return typeof what !== 'undefined'; | ||
} | ||
// creates camelCased aliases for all the keys of an object | ||
function alias_camel_case(object) { | ||
var _iteratorNormalCompletion2 = true; | ||
var _didIteratorError2 = false; | ||
var _iteratorError2 = undefined; | ||
try { | ||
for (var _iterator2 = _getIterator(_Object$keys(object)), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { | ||
var key = _step2.value; | ||
if (key.indexOf('_') >= 0) { | ||
var camel_cased_key = key.replace(/_(.)/g, function (match, group_1) { | ||
return group_1.toUpperCase(); | ||
}); | ||
if (!exists(object[camel_cased_key])) { | ||
object[camel_cased_key] = object[key]; | ||
} | ||
} | ||
} | ||
} catch (err) { | ||
_didIteratorError2 = true; | ||
_iteratorError2 = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion2 && _iterator2['return']) { | ||
_iterator2['return'](); | ||
} | ||
} finally { | ||
if (_didIteratorError2) { | ||
throw _iteratorError2; | ||
} | ||
} | ||
} | ||
return object; | ||
} | ||
//# sourceMappingURL=helpers.js.map |
@@ -49,3 +49,3 @@ 'use strict'; | ||
// take the passed in options | ||
this.options = (0, _helpers.clone)(options); | ||
this.options = (0, _helpers.alias_camel_case)((0, _helpers.clone)(options)); | ||
@@ -249,3 +249,4 @@ // a list of files which can be require()d normally on the server | ||
if (!asset_path) { | ||
return ''; | ||
// return '' | ||
return undefined; | ||
} | ||
@@ -267,3 +268,3 @@ | ||
// if the real path was found in the list - return it | ||
if (asset) { | ||
if ((0, _helpers.exists)(asset)) { | ||
return asset; | ||
@@ -289,3 +290,4 @@ } | ||
this.log.error('asset not found: ' + asset_path); | ||
return ''; | ||
// return '' | ||
return undefined; | ||
} | ||
@@ -292,0 +294,0 @@ }, { |
@@ -38,3 +38,3 @@ 'use strict'; | ||
// take the passed in options | ||
this.options = (0, _helpers.clone)(options); | ||
this.options = (0, _helpers.alias_camel_case)((0, _helpers.clone)(options)); | ||
@@ -51,2 +51,5 @@ // add missing fields, etc | ||
// alias camel case for those who prefer it | ||
this.regularExpressions = this.regular_expressions; | ||
// for each user defined asset type | ||
@@ -191,3 +194,6 @@ var _iteratorNormalCompletion = true; | ||
}; | ||
// alias camel case for those who prefer it | ||
Plugin.urlLoaderParser = Plugin.url_loader_parser; | ||
module.exports = exports['default']; | ||
//# sourceMappingURL=plugin.js.map |
{ | ||
"name": "webpack-isomorphic-tools", | ||
"version": "0.8.5", | ||
"version": "0.8.6", | ||
"description": "Transforms CSS-alike text into a React style JSON object", | ||
@@ -5,0 +5,0 @@ "main": "babel-transpiled-modules/index.js", |
@@ -63,2 +63,4 @@ # webpack-isomorphic-tools | ||
`webpack-isomorphic-tools` are required both for development and production | ||
```bash | ||
@@ -65,0 +67,0 @@ $ npm install webpack-isomorphic-tools --save |
@@ -43,2 +43,24 @@ // // if the variable is defined | ||
return merge({}, object) | ||
} | ||
// creates camelCased aliases for all the keys of an object | ||
export function alias_camel_case(object) | ||
{ | ||
for (let key of Object.keys(object)) | ||
{ | ||
if (key.indexOf('_') >= 0) | ||
{ | ||
const camel_cased_key = key.replace(/_(.)/g, function(match, group_1) | ||
{ | ||
return group_1.toUpperCase() | ||
}) | ||
if (!exists(object[camel_cased_key])) | ||
{ | ||
object[camel_cased_key] = object[key] | ||
} | ||
} | ||
} | ||
return object | ||
} |
@@ -8,3 +8,3 @@ import path from 'path' | ||
import { exists, clone } from './helpers' | ||
import { exists, clone, alias_camel_case } from './helpers' | ||
import { default_webpack_assets, normalize_options } from './common' | ||
@@ -19,3 +19,3 @@ | ||
// take the passed in options | ||
this.options = clone(options) | ||
this.options = alias_camel_case(clone(options)) | ||
@@ -181,3 +181,4 @@ // a list of files which can be require()d normally on the server | ||
{ | ||
return '' | ||
// return '' | ||
return undefined | ||
} | ||
@@ -193,3 +194,3 @@ | ||
// if the real path was found in the list - return it | ||
if (asset) | ||
if (exists(asset)) | ||
{ | ||
@@ -202,3 +203,4 @@ return asset | ||
this.log.error(`asset not found: ${asset_path}`) | ||
return '' | ||
// return '' | ||
return undefined | ||
} | ||
@@ -205,0 +207,0 @@ |
@@ -8,3 +8,3 @@ import path from 'path' | ||
import { exists, clone } from './../helpers' | ||
import { exists, clone, alias_camel_case } from './../helpers' | ||
@@ -17,3 +17,3 @@ import { default_webpack_assets, normalize_options } from './../common' | ||
// take the passed in options | ||
this.options = clone(options) | ||
this.options = alias_camel_case(clone(options)) | ||
@@ -30,2 +30,5 @@ // add missing fields, etc | ||
// alias camel case for those who prefer it | ||
this.regularExpressions = this.regular_expressions | ||
// for each user defined asset type | ||
@@ -167,2 +170,5 @@ for (let asset_type of Object.keys(this.options.assets)) | ||
return asset_path | ||
} | ||
} | ||
// alias camel case for those who prefer it | ||
Plugin.urlLoaderParser = Plugin.url_loader_parser |
import chai from 'chai' | ||
import { extend } from './../source/helpers' | ||
import { extend, alias_camel_case } from './../source/helpers' | ||
@@ -39,2 +39,32 @@ chai.should() | ||
}) | ||
it('should alias camel case', function() | ||
{ | ||
const a = | ||
{ | ||
a: 1, | ||
b_cd_ef: | ||
{ | ||
g_h: true | ||
} | ||
} | ||
const camel_cased_a = | ||
{ | ||
a: 1, | ||
b_cd_ef: | ||
{ | ||
g_h: true | ||
}, | ||
bCdEf: | ||
{ | ||
g_h: true | ||
} | ||
} | ||
alias_camel_case(a).should.deep.equal(camel_cased_a) | ||
}) | ||
}) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
164099
2416
625