Comparing version 1.0.7-alpha.1 to 1.0.7-alpha.2
@@ -51,4 +51,4 @@ "use strict"; | ||
rule.toModule(context, out); | ||
chai_1.expect(out.toString()).to.eq('brand = {}\nbrand.global = {}\nbrand.global.dark = $J.get($VARS, \'brand.global.dark\', $J.anon("#000"))\nbrand.dark = $J.get($VARS, \'brand.dark\', $J.anon("#222"))\nbrand.light = $J.get($VARS, \'brand.light\', $J.anon("#eee"))\n'); | ||
chai_1.expect(out.toString()).to.eq('brand = $J.merge({}, $J.get($VARS, \'brand\'))\nbrand.global = {}\nbrand.global.dark = $J.get($VARS, \'brand.global.dark\', $J.anon("#000"))\nbrand.dark = $J.get($VARS, \'brand.dark\', $J.anon("#222"))\nbrand.light = $J.get($VARS, \'brand.light\', $J.anon("#eee"))\n'); | ||
}); | ||
}); |
@@ -25,3 +25,8 @@ "use strict"; | ||
if (value instanceof _1.JsCollection) { | ||
out.add(`${keys.join('.')} = {}\n${pre}`); | ||
if (keys.length === 1) { | ||
out.add(`${keys[0]} = $J.merge({}, $J.get($VARS, '${keys[0]}'))\n${pre}`); | ||
} | ||
else { | ||
out.add(`${keys.join('.')} = {}\n${pre}`); | ||
} | ||
value.value.forEach(node => { | ||
@@ -45,6 +50,3 @@ this.recurseValue(node.value, [...keys, node.name.value], context, out); | ||
if (context.rootLevel !== 1) { | ||
out.add(`let `); | ||
} | ||
if (context.rootLevel !== 1) { | ||
out.add(`${name} = `); | ||
out.add(`let ${name} = `); | ||
this.value.value.toModule(context, out); | ||
@@ -51,0 +53,0 @@ return; |
@@ -5,5 +5,4 @@ /// <reference types="lodash" /> | ||
* Use lodash merge for objects, return plain value otherwise | ||
* | ||
* @todo - remove? | ||
*/ | ||
export declare const merge: (value: any, incomingValue: any) => any; | ||
export declare const get: { | ||
@@ -34,2 +33,2 @@ <TObject extends object, TKey extends keyof TObject>(object: TObject, path: TKey | [TKey]): TObject[TKey]; | ||
*/ | ||
export declare const proxy: (func: Function, context: Context) => import("micro-memoize").MicroMemoize.Memoized<Function>; | ||
export declare const proxy: (func: Function, context: Context) => any; |
@@ -6,3 +6,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.proxy = exports.get = void 0; | ||
exports.proxy = exports.get = exports.merge = void 0; | ||
const isPlainObject_1 = __importDefault(require("lodash/isPlainObject")); | ||
const merge_1 = __importDefault(require("lodash/merge")); | ||
const get_1 = __importDefault(require("lodash/get")); | ||
@@ -12,17 +14,16 @@ const micro_memoize_1 = __importDefault(require("micro-memoize")); | ||
* Use lodash merge for objects, return plain value otherwise | ||
* | ||
* @todo - remove? | ||
*/ | ||
// export const merge = (value: any, incomingValue: any) => { | ||
// if (incomingValue === undefined) { | ||
// return value | ||
// } | ||
// if (isPlainObject(value)) { | ||
// if (isPlainObject(incomingValue)) { | ||
// return lodashMerge({}, value, incomingValue) | ||
// } | ||
// return value | ||
// } | ||
// return incomingValue | ||
// } | ||
const merge = (value, incomingValue) => { | ||
if (incomingValue === undefined) { | ||
return value; | ||
} | ||
if (isPlainObject_1.default(value)) { | ||
if (isPlainObject_1.default(incomingValue)) { | ||
return merge_1.default({}, value, incomingValue); | ||
} | ||
return value; | ||
} | ||
return incomingValue; | ||
}; | ||
exports.merge = merge; | ||
exports.get = get_1.default; | ||
@@ -35,3 +36,3 @@ /** | ||
const proxy = (func, context) => { | ||
const memo = micro_memoize_1.default(func); | ||
const memo = micro_memoize_1.default(func.bind(context)); | ||
return new Proxy(memo, { | ||
@@ -38,0 +39,0 @@ get(target, p) { |
{ | ||
"name": "jess", | ||
"version": "1.0.7-alpha.1", | ||
"version": "1.0.7-alpha.2", | ||
"description": "JavaScript Enhanced Style Sheets", | ||
@@ -48,3 +48,3 @@ "main": "lib/index", | ||
}, | ||
"gitHead": "dafa15e004b31af3c572516a0ee34beabc1827ae" | ||
"gitHead": "d08d332a099e610258cdbd7c58c38a9719e1678d" | ||
} |
151481
4236