|
|
|
@ -6,268 +6,294 @@
|
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import {assertEqual} from './assert';
|
|
|
|
|
import {NO_CHANGE, bind, getTView} from './instructions';
|
|
|
|
|
|
|
|
|
|
import {NO_CHANGE, bind, peekBinding} from './instructions';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Updates an expression in an object or array literal if the expression has changed.
|
|
|
|
|
* Used in objectLiteral instructions.
|
|
|
|
|
*
|
|
|
|
|
* @param obj Object to update
|
|
|
|
|
* @param key Key to set in object
|
|
|
|
|
* @param exp Expression to set at key
|
|
|
|
|
* @returns Whether or not there has been a change
|
|
|
|
|
*/
|
|
|
|
|
function updateBinding(obj: any, key: string | number, exp: any): boolean {
|
|
|
|
|
if (bind(exp) !== NO_CHANGE) {
|
|
|
|
|
obj[key] = exp;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Updates two expressions in an object or array literal if they have changed. */
|
|
|
|
|
function updateBinding2(
|
|
|
|
|
obj: any, key1: string | number, exp1: any, key2: string | number, exp2: any): boolean {
|
|
|
|
|
let different = updateBinding(obj, key1, exp1);
|
|
|
|
|
return updateBinding(obj, key2, exp2) || different;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Updates four expressions in an object or array literal if they have changed. */
|
|
|
|
|
function updateBinding4(
|
|
|
|
|
obj: any, key1: string | number, exp1: any, key2: string | number, exp2: any,
|
|
|
|
|
key3: string | number, exp3: any, key4: string | number, exp4: any): boolean {
|
|
|
|
|
let different = updateBinding2(obj, key1, exp1, key2, exp2);
|
|
|
|
|
return updateBinding2(obj, key3, exp3, key4, exp4) || different;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets a blueprint of an object or array if one has already been saved, or copies the
|
|
|
|
|
* object and saves it for the next change detection run if it hasn't.
|
|
|
|
|
*/
|
|
|
|
|
function getMutableBlueprint(index: number, obj: any): any {
|
|
|
|
|
const tView = getTView();
|
|
|
|
|
const objectLiterals = tView.objectLiterals;
|
|
|
|
|
if (objectLiterals && index < objectLiterals.length) {
|
|
|
|
|
return objectLiterals[index];
|
|
|
|
|
} else {
|
|
|
|
|
ngDevMode && objectLiterals && assertEqual(index, objectLiterals.length, 'index');
|
|
|
|
|
return (objectLiterals || (tView.objectLiterals = []))[index] = copyObject(obj);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** Copies an object or array */
|
|
|
|
|
function copyObject(obj: any): any {
|
|
|
|
|
return Array.isArray(obj) ? obj.slice() : {...obj};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Updates the expression in the given object or array if it has changed and returns a copy.
|
|
|
|
|
* If the object or array has changed, returns a copy with the updated expression.
|
|
|
|
|
* Or if the expression hasn't changed, returns NO_CHANGE.
|
|
|
|
|
*
|
|
|
|
|
* @param objIndex Index of object blueprint in objectLiterals
|
|
|
|
|
* @param obj Object to update
|
|
|
|
|
* @param key Key to set in object
|
|
|
|
|
* @param exp Expression to set at key
|
|
|
|
|
* @returns A copy of the object or NO_CHANGE
|
|
|
|
|
* @param factoryFn Function that returns an updated instance of the object/array
|
|
|
|
|
* @param exp Updated expression value
|
|
|
|
|
* @returns A copy of the object/array or NO_CHANGE
|
|
|
|
|
*/
|
|
|
|
|
export function objectLiteral1(objIndex: number, obj: any, key: string | number, exp: any): any {
|
|
|
|
|
obj = getMutableBlueprint(objIndex, obj);
|
|
|
|
|
if (bind(exp) === NO_CHANGE) {
|
|
|
|
|
return NO_CHANGE;
|
|
|
|
|
} else {
|
|
|
|
|
obj[key] = exp;
|
|
|
|
|
// Must copy to change identity when binding changes
|
|
|
|
|
return copyObject(obj);
|
|
|
|
|
}
|
|
|
|
|
export function objectLiteral1(factoryFn: (v: any) => any, exp: any): any {
|
|
|
|
|
let different = false;
|
|
|
|
|
const latestValue = exp === NO_CHANGE ? peekBinding() : exp;
|
|
|
|
|
if (bind(exp) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
return different ? factoryFn(latestValue) : NO_CHANGE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Updates the expressions in the given object or array if they have changed and returns a copy.
|
|
|
|
|
* If the object or array has changed, returns a copy with all updated expressions.
|
|
|
|
|
* Or if no expressions have changed, returns NO_CHANGE.
|
|
|
|
|
*
|
|
|
|
|
* @param objIndex
|
|
|
|
|
* @param obj
|
|
|
|
|
* @param key1
|
|
|
|
|
* @param factoryFn
|
|
|
|
|
* @param exp1
|
|
|
|
|
* @param key2
|
|
|
|
|
* @param exp2
|
|
|
|
|
* @returns A copy of the array or NO_CHANGE
|
|
|
|
|
* @returns A copy of the object/array or NO_CHANGE
|
|
|
|
|
*/
|
|
|
|
|
export function objectLiteral2(
|
|
|
|
|
objIndex: number, obj: any, key1: string | number, exp1: any, key2: string | number,
|
|
|
|
|
exp2: any): any {
|
|
|
|
|
obj = getMutableBlueprint(objIndex, obj);
|
|
|
|
|
return updateBinding2(obj, key1, exp1, key2, exp2) ? copyObject(obj) : NO_CHANGE;
|
|
|
|
|
export function objectLiteral2(factoryFn: (v1: any, v2: any) => any, exp1: any, exp2: any): any {
|
|
|
|
|
let different = false;
|
|
|
|
|
|
|
|
|
|
const latestVal1 = exp1 === NO_CHANGE ? peekBinding() : exp1;
|
|
|
|
|
if (bind(exp1) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
const latestVal2 = exp2 === NO_CHANGE ? peekBinding() : exp2;
|
|
|
|
|
if (bind(exp2) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
return different ? factoryFn(latestVal1, latestVal2) : NO_CHANGE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Updates the expressions in the given object or array if they have changed and returns a copy.
|
|
|
|
|
* If the object or array has changed, returns a copy with all updated expressions.
|
|
|
|
|
* Or if no expressions have changed, returns NO_CHANGE.
|
|
|
|
|
*
|
|
|
|
|
* @param objIndex
|
|
|
|
|
* @param obj
|
|
|
|
|
* @param key1
|
|
|
|
|
* @param factoryFn
|
|
|
|
|
* @param exp1
|
|
|
|
|
* @param key2
|
|
|
|
|
* @param exp2
|
|
|
|
|
* @param key3
|
|
|
|
|
* @param exp3
|
|
|
|
|
* @returns A copy of the object or NO_CHANGE
|
|
|
|
|
* @returns A copy of the object/array or NO_CHANGE
|
|
|
|
|
*/
|
|
|
|
|
export function objectLiteral3(
|
|
|
|
|
objIndex: number, obj: any, key1: string | number, exp1: any, key2: string | number, exp2: any,
|
|
|
|
|
key3: string | number, exp3: any): any {
|
|
|
|
|
obj = getMutableBlueprint(objIndex, obj);
|
|
|
|
|
let different = updateBinding2(obj, key1, exp1, key2, exp2);
|
|
|
|
|
return updateBinding(obj, key3, exp3) || different ? copyObject(obj) : NO_CHANGE;
|
|
|
|
|
factoryFn: (v1: any, v2: any, v3: any) => any, exp1: any, exp2: any, exp3: any): any {
|
|
|
|
|
let different = false;
|
|
|
|
|
|
|
|
|
|
const latestVal1 = exp1 === NO_CHANGE ? peekBinding() : exp1;
|
|
|
|
|
if (bind(exp1) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
const latestVal2 = exp2 === NO_CHANGE ? peekBinding() : exp2;
|
|
|
|
|
if (bind(exp2) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
const latestVal3 = exp3 === NO_CHANGE ? peekBinding() : exp3;
|
|
|
|
|
if (bind(exp3) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
return different ? factoryFn(latestVal1, latestVal2, latestVal3) : NO_CHANGE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Updates the expressions in the given object or array if they have changed and returns a copy.
|
|
|
|
|
* If the object or array has changed, returns a copy with all updated expressions.
|
|
|
|
|
* Or if no expressions have changed, returns NO_CHANGE.
|
|
|
|
|
*
|
|
|
|
|
* @param objIndex
|
|
|
|
|
* @param obj
|
|
|
|
|
* @param key1
|
|
|
|
|
* @param factoryFn
|
|
|
|
|
* @param exp1
|
|
|
|
|
* @param key2
|
|
|
|
|
* @param exp2
|
|
|
|
|
* @param key3
|
|
|
|
|
* @param exp3
|
|
|
|
|
* @param key4
|
|
|
|
|
* @param exp4
|
|
|
|
|
* @returns A copy of the object or NO_CHANGE
|
|
|
|
|
* @returns A copy of the object/array or NO_CHANGE
|
|
|
|
|
*/
|
|
|
|
|
export function objectLiteral4(
|
|
|
|
|
objIndex: number, obj: any, key1: string | number, exp1: any, key2: string | number, exp2: any,
|
|
|
|
|
key3: string | number, exp3: any, key4: string | number, exp4: any): any {
|
|
|
|
|
obj = getMutableBlueprint(objIndex, obj);
|
|
|
|
|
return updateBinding4(obj, key1, exp1, key2, exp2, key3, exp3, key4, exp4) ? copyObject(obj) :
|
|
|
|
|
NO_CHANGE;
|
|
|
|
|
factoryFn: (v1: any, v2: any, v3: any, v4: any) => any, exp1: any, exp2: any, exp3: any,
|
|
|
|
|
exp4: any): any {
|
|
|
|
|
let different = false;
|
|
|
|
|
|
|
|
|
|
const latestVal1 = exp1 === NO_CHANGE ? peekBinding() : exp1;
|
|
|
|
|
if (bind(exp1) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
const latestVal2 = exp2 === NO_CHANGE ? peekBinding() : exp2;
|
|
|
|
|
if (bind(exp2) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
const latestVal3 = exp3 === NO_CHANGE ? peekBinding() : exp3;
|
|
|
|
|
if (bind(exp3) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
const latestVal4 = exp4 === NO_CHANGE ? peekBinding() : exp4;
|
|
|
|
|
if (bind(exp4) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
return different ? factoryFn(latestVal1, latestVal2, latestVal3, latestVal4) : NO_CHANGE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Updates the expressions in the given object or array if they have changed and returns a copy.
|
|
|
|
|
* If the object or array has changed, returns a copy with all updated expressions.
|
|
|
|
|
* Or if no expressions have changed, returns NO_CHANGE.
|
|
|
|
|
*
|
|
|
|
|
* @param objIndex
|
|
|
|
|
* @param obj
|
|
|
|
|
* @param key1
|
|
|
|
|
* @param factoryFn
|
|
|
|
|
* @param exp1
|
|
|
|
|
* @param key2
|
|
|
|
|
* @param exp2
|
|
|
|
|
* @param key3
|
|
|
|
|
* @param exp3
|
|
|
|
|
* @param key4
|
|
|
|
|
* @param exp4
|
|
|
|
|
* @param key5
|
|
|
|
|
* @param exp5
|
|
|
|
|
* @returns A copy of the object or NO_CHANGE
|
|
|
|
|
* @returns A copy of the object/array or NO_CHANGE
|
|
|
|
|
*/
|
|
|
|
|
export function objectLiteral5(
|
|
|
|
|
objIndex: number, obj: any, key1: string | number, exp1: any, key2: string | number, exp2: any,
|
|
|
|
|
key3: string | number, exp3: any, key4: string | number, exp4: any, key5: string | number,
|
|
|
|
|
exp5: any): any {
|
|
|
|
|
obj = getMutableBlueprint(objIndex, obj);
|
|
|
|
|
let different = updateBinding4(obj, key1, exp1, key2, exp2, key3, exp3, key4, exp4);
|
|
|
|
|
return updateBinding(obj, key5, exp5) || different ? copyObject(obj) : NO_CHANGE;
|
|
|
|
|
factoryFn: (v1: any, v2: any, v3: any, v4: any, v5: any) => any, exp1: any, exp2: any,
|
|
|
|
|
exp3: any, exp4: any, exp5: any): any {
|
|
|
|
|
let different = false;
|
|
|
|
|
|
|
|
|
|
const latestVal1 = exp1 === NO_CHANGE ? peekBinding() : exp1;
|
|
|
|
|
if (bind(exp1) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
const latestVal2 = exp2 === NO_CHANGE ? peekBinding() : exp2;
|
|
|
|
|
if (bind(exp2) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
const latestVal3 = exp3 === NO_CHANGE ? peekBinding() : exp3;
|
|
|
|
|
if (bind(exp3) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
const latestVal4 = exp4 === NO_CHANGE ? peekBinding() : exp4;
|
|
|
|
|
if (bind(exp4) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
const latestVal5 = exp5 === NO_CHANGE ? peekBinding() : exp5;
|
|
|
|
|
if (bind(exp5) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
return different ? factoryFn(latestVal1, latestVal2, latestVal3, latestVal4, latestVal5) :
|
|
|
|
|
NO_CHANGE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Updates the expressions in the given object or array if they have changed and returns a copy.
|
|
|
|
|
* If the object or array has changed, returns a copy with all updated expressions.
|
|
|
|
|
* Or if no expressions have changed, returns NO_CHANGE.
|
|
|
|
|
*
|
|
|
|
|
* @param objIndex
|
|
|
|
|
* @param obj
|
|
|
|
|
* @param key1
|
|
|
|
|
* @param factoryFn
|
|
|
|
|
* @param exp1
|
|
|
|
|
* @param key2
|
|
|
|
|
* @param exp2
|
|
|
|
|
* @param key3
|
|
|
|
|
* @param exp3
|
|
|
|
|
* @param key4
|
|
|
|
|
* @param exp4
|
|
|
|
|
* @param key5
|
|
|
|
|
* @param exp5
|
|
|
|
|
* @param key6
|
|
|
|
|
* @param exp6
|
|
|
|
|
* @returns A copy of the object or NO_CHANGE
|
|
|
|
|
* @returns A copy of the object/array or NO_CHANGE
|
|
|
|
|
*/
|
|
|
|
|
export function objectLiteral6(
|
|
|
|
|
objIndex: number, obj: any, key1: string | number, exp1: any, key2: string | number, exp2: any,
|
|
|
|
|
key3: string | number, exp3: any, key4: string | number, exp4: any, key5: string | number,
|
|
|
|
|
exp5: any, key6: string | number, exp6: any): any {
|
|
|
|
|
obj = getMutableBlueprint(objIndex, obj);
|
|
|
|
|
let different = updateBinding4(obj, key1, exp1, key2, exp2, key3, exp3, key4, exp4);
|
|
|
|
|
return updateBinding2(obj, key5, exp5, key6, exp6) || different ? copyObject(obj) : NO_CHANGE;
|
|
|
|
|
}
|
|
|
|
|
factoryFn: (v1: any, v2: any, v3: any, v4: any, v5: any, v6: any) => any, exp1: any, exp2: any,
|
|
|
|
|
exp3: any, exp4: any, exp5: any, exp6: any): any {
|
|
|
|
|
let different = false;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Updates the expressions in the given object or array if they have changed and returns a copy.
|
|
|
|
|
* Or if no expressions have changed, returns NO_CHANGE.
|
|
|
|
|
*
|
|
|
|
|
* @param objIndex
|
|
|
|
|
* @param obj
|
|
|
|
|
* @param key1
|
|
|
|
|
* @param exp1
|
|
|
|
|
* @param key2
|
|
|
|
|
* @param exp2
|
|
|
|
|
* @param key3
|
|
|
|
|
* @param exp3
|
|
|
|
|
* @param key4
|
|
|
|
|
* @param exp4
|
|
|
|
|
* @param key5
|
|
|
|
|
* @param exp5
|
|
|
|
|
* @param key6
|
|
|
|
|
* @param exp6
|
|
|
|
|
* @param key7
|
|
|
|
|
* @param exp7
|
|
|
|
|
* @returns A copy of the object or NO_CHANGE
|
|
|
|
|
*/
|
|
|
|
|
export function objectLiteral7(
|
|
|
|
|
objIndex: number, obj: any, key1: string | number, exp1: any, key2: string | number, exp2: any,
|
|
|
|
|
key3: string | number, exp3: any, key4: string | number, exp4: any, key5: string | number,
|
|
|
|
|
exp5: any, key6: string | number, exp6: any, key7: string | number, exp7: any): any {
|
|
|
|
|
obj = getMutableBlueprint(objIndex, obj);
|
|
|
|
|
let different = updateBinding4(obj, key1, exp1, key2, exp2, key3, exp3, key4, exp4);
|
|
|
|
|
different = updateBinding2(obj, key5, exp5, key6, exp6) || different;
|
|
|
|
|
return updateBinding(obj, key7, exp7) || different ? copyObject(obj) : NO_CHANGE;
|
|
|
|
|
}
|
|
|
|
|
const latestVal1 = exp1 === NO_CHANGE ? peekBinding() : exp1;
|
|
|
|
|
if (bind(exp1) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Updates the expressions in the given object or array if they have changed and returns a copy.
|
|
|
|
|
* Or if no expressions have changed, returns NO_CHANGE.
|
|
|
|
|
*
|
|
|
|
|
* @param objIndex
|
|
|
|
|
* @param obj
|
|
|
|
|
* @param key1
|
|
|
|
|
* @param exp1
|
|
|
|
|
* @param key2
|
|
|
|
|
* @param exp2
|
|
|
|
|
* @param key3
|
|
|
|
|
* @param exp3
|
|
|
|
|
* @param key4
|
|
|
|
|
* @param exp4
|
|
|
|
|
* @param key5
|
|
|
|
|
* @param exp5
|
|
|
|
|
* @param key6
|
|
|
|
|
* @param exp6
|
|
|
|
|
* @param key7
|
|
|
|
|
* @param exp7
|
|
|
|
|
* @param key8
|
|
|
|
|
* @param exp8
|
|
|
|
|
* @returns A copy of the object or NO_CHANGE
|
|
|
|
|
*/
|
|
|
|
|
export function objectLiteral8(
|
|
|
|
|
objIndex: number, obj: any, key1: string | number, exp1: any, key2: string | number, exp2: any,
|
|
|
|
|
key3: string | number, exp3: any, key4: string | number, exp4: any, key5: string | number,
|
|
|
|
|
exp5: any, key6: string | number, exp6: any, key7: string | number, exp7: any,
|
|
|
|
|
key8: string | number, exp8: any): any {
|
|
|
|
|
obj = getMutableBlueprint(objIndex, obj);
|
|
|
|
|
let different = updateBinding4(obj, key1, exp1, key2, exp2, key3, exp3, key4, exp4);
|
|
|
|
|
return updateBinding4(obj, key5, exp5, key6, exp6, key7, exp7, key8, exp8) || different ?
|
|
|
|
|
copyObject(obj) :
|
|
|
|
|
const latestVal2 = exp2 === NO_CHANGE ? peekBinding() : exp2;
|
|
|
|
|
if (bind(exp2) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
const latestVal3 = exp3 === NO_CHANGE ? peekBinding() : exp3;
|
|
|
|
|
if (bind(exp3) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
const latestVal4 = exp4 === NO_CHANGE ? peekBinding() : exp4;
|
|
|
|
|
if (bind(exp4) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
const latestVal5 = exp5 === NO_CHANGE ? peekBinding() : exp5;
|
|
|
|
|
if (bind(exp5) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
const latestVal6 = exp6 === NO_CHANGE ? peekBinding() : exp6;
|
|
|
|
|
if (bind(exp6) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
return different ?
|
|
|
|
|
factoryFn(latestVal1, latestVal2, latestVal3, latestVal4, latestVal5, latestVal6) :
|
|
|
|
|
NO_CHANGE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* If the object or array has changed, returns a copy with all updated expressions.
|
|
|
|
|
* Or if no expressions have changed, returns NO_CHANGE.
|
|
|
|
|
*
|
|
|
|
|
* @param factoryFn
|
|
|
|
|
* @param exp1
|
|
|
|
|
* @param exp2
|
|
|
|
|
* @param exp3
|
|
|
|
|
* @param exp4
|
|
|
|
|
* @param exp5
|
|
|
|
|
* @param exp6
|
|
|
|
|
* @param exp7
|
|
|
|
|
* @returns A copy of the object/array or NO_CHANGE
|
|
|
|
|
*/
|
|
|
|
|
export function objectLiteral7(
|
|
|
|
|
factoryFn: (v1: any, v2: any, v3: any, v4: any, v5: any, v6: any, v7: any) => any, exp1: any,
|
|
|
|
|
exp2: any, exp3: any, exp4: any, exp5: any, exp6: any, exp7: any): any {
|
|
|
|
|
let different = false;
|
|
|
|
|
|
|
|
|
|
const latestVal1 = exp1 === NO_CHANGE ? peekBinding() : exp1;
|
|
|
|
|
if (bind(exp1) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
const latestVal2 = exp2 === NO_CHANGE ? peekBinding() : exp2;
|
|
|
|
|
if (bind(exp2) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
const latestVal3 = exp3 === NO_CHANGE ? peekBinding() : exp3;
|
|
|
|
|
if (bind(exp3) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
const latestVal4 = exp4 === NO_CHANGE ? peekBinding() : exp4;
|
|
|
|
|
if (bind(exp4) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
const latestVal5 = exp5 === NO_CHANGE ? peekBinding() : exp5;
|
|
|
|
|
if (bind(exp5) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
const latestVal6 = exp6 === NO_CHANGE ? peekBinding() : exp6;
|
|
|
|
|
if (bind(exp6) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
const latestVal7 = exp7 === NO_CHANGE ? peekBinding() : exp7;
|
|
|
|
|
if (bind(exp7) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
return different ?
|
|
|
|
|
factoryFn(
|
|
|
|
|
latestVal1, latestVal2, latestVal3, latestVal4, latestVal5, latestVal6, latestVal7) :
|
|
|
|
|
NO_CHANGE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* If the object or array has changed, returns a copy with all updated expressions.
|
|
|
|
|
* Or if no expressions have changed, returns NO_CHANGE.
|
|
|
|
|
*
|
|
|
|
|
* @param factoryFn
|
|
|
|
|
* @param exp1
|
|
|
|
|
* @param exp2
|
|
|
|
|
* @param exp3
|
|
|
|
|
* @param exp4
|
|
|
|
|
* @param exp5
|
|
|
|
|
* @param exp6
|
|
|
|
|
* @param exp7
|
|
|
|
|
* @param exp8
|
|
|
|
|
* @returns A copy of the object/array or NO_CHANGE
|
|
|
|
|
*/
|
|
|
|
|
export function objectLiteral8(
|
|
|
|
|
factoryFn: (v1: any, v2: any, v3: any, v4: any, v5: any, v6: any, v7: any, v8: any) => any,
|
|
|
|
|
exp1: any, exp2: any, exp3: any, exp4: any, exp5: any, exp6: any, exp7: any, exp8: any): any {
|
|
|
|
|
let different = false;
|
|
|
|
|
|
|
|
|
|
const latestVal1 = exp1 === NO_CHANGE ? peekBinding() : exp1;
|
|
|
|
|
if (bind(exp1) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
const latestVal2 = exp2 === NO_CHANGE ? peekBinding() : exp2;
|
|
|
|
|
if (bind(exp2) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
const latestVal3 = exp3 === NO_CHANGE ? peekBinding() : exp3;
|
|
|
|
|
if (bind(exp3) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
const latestVal4 = exp4 === NO_CHANGE ? peekBinding() : exp4;
|
|
|
|
|
if (bind(exp4) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
const latestVal5 = exp5 === NO_CHANGE ? peekBinding() : exp5;
|
|
|
|
|
if (bind(exp5) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
const latestVal6 = exp6 === NO_CHANGE ? peekBinding() : exp6;
|
|
|
|
|
if (bind(exp6) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
const latestVal7 = exp7 === NO_CHANGE ? peekBinding() : exp7;
|
|
|
|
|
if (bind(exp7) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
const latestVal8 = exp8 === NO_CHANGE ? peekBinding() : exp8;
|
|
|
|
|
if (bind(exp8) !== NO_CHANGE) different = true;
|
|
|
|
|
|
|
|
|
|
return different ? factoryFn(
|
|
|
|
|
latestVal1, latestVal2, latestVal3, latestVal4, latestVal5, latestVal6,
|
|
|
|
|
latestVal7, latestVal8) :
|
|
|
|
|
NO_CHANGE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* objectLiteral instruction that can support any number of bindings.
|
|
|
|
|
*
|
|
|
|
|
* If the object or array has changed, returns a copy with all updated expressions.
|
|
|
|
|
* Or if no expressions have changed, returns NO_CHANGE.
|
|
|
|
|
*
|
|
|
|
|
* @param factoryFn A factory function that takes binding values and builds an object or array
|
|
|
|
|
* containing those values.
|
|
|
|
|
* @param exp An array of binding values
|
|
|
|
|
* @returns A copy of the object/array or NO_CHANGE
|
|
|
|
|
*/
|
|
|
|
|
export function objectLiteralV(factoryFn: (v: any[]) => any, exps: any[]): any {
|
|
|
|
|
let different = false;
|
|
|
|
|
|
|
|
|
|
for (let i = 0; i < exps.length; i++) {
|
|
|
|
|
const exp = exps[i];
|
|
|
|
|
if (exp === NO_CHANGE) exps[i] = peekBinding();
|
|
|
|
|
if (bind(exp) !== NO_CHANGE) different = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return different ? factoryFn(exps) : NO_CHANGE;
|
|
|
|
|
}
|
|
|
|
|