Skip to content
This repository has been archived by the owner on Jun 3, 2022. It is now read-only.

Commit

Permalink
Renames possibleValues to limitedToValues. Closes #58. (#59)
Browse files Browse the repository at this point in the history
* Renames possibleValues to limitedToValues throughout codebase. Closes #58.

* Updates comments.
  • Loading branch information
chriscox authored Jan 5, 2017
1 parent aac1e82 commit c795fd8
Show file tree
Hide file tree
Showing 16 changed files with 86 additions and 85 deletions.
42 changes: 21 additions & 21 deletions src/core/Remixer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,60 +168,60 @@ class Remixer {

/**
* Adds a string Variable to array of variables with optional callback
* @param {string} key The key of the Variable.
* @param {string} defaultValue The initial default value of the variable.
* @param {string[]} possibleValues The optional array of available items for the variable.
* @param {IVariableCallback} callback The callback method to be invoked
* when the Variable is updated.
* @param {string} key The key of the Variable.
* @param {string} defaultValue The initial default value of the variable.
* @param {string[]} limitedToValues The optional array of allowed values.
* @param {IVariableCallback} callback The callback method to be invoked
* when the Variable is updated.
* @return {StringVariable}
*/
static addStringVariable(
key: string,
defaultValue: string,
possibleValues?: string[],
limitedToValues?: string[],
callback?: IVariableCallback,
): StringVariable {
let variable = new StringVariable(key, defaultValue, possibleValues, callback);
let variable = new StringVariable(key, defaultValue, limitedToValues, callback);
this.addVariable(variable);
return variable;
}

/**
* Adds a number variable to array of variables with optional callback.
* @param {string} key The key of the Variable.
* @param {number} defaultValue The initial default value of the variable.
* @param {number[]} possibleValues The optional array of available items for the variable.
* @param {IVariableCallback} callback The callback method to be invoked
* when the Variable is updated.
* @param {string} key The key of the Variable.
* @param {number} defaultValue The initial default value of the variable.
* @param {number[]} limitedToValues The optional array of allowed values.
* @param {IVariableCallback} callback The callback method to be invoked
* when the Variable is updated.
* @return {NumberVariable}
*/
static addNumberVariable(
key: string,
defaultValue: number,
possibleValues?: number[],
limitedToValues?: number[],
callback?: IVariableCallback,
): NumberVariable {
let variable = new NumberVariable(key, defaultValue, possibleValues, callback);
let variable = new NumberVariable(key, defaultValue, limitedToValues, callback);
this.addVariable(variable);
return variable;
}

/**
* Adds a color variable to array of variables with optional callback.
* @param {string} key The key of the Variable.
* @param {string} defaultValue The initial default value of the variable.
* @param {string[]} possibleValues The optional array of available items for the variable.
* @param {IVariableCallback} callback The callback method to be invoked
* when the Variable is updated.
* @param {string} key The key of the Variable.
* @param {string} defaultValue The initial default value of the variable.
* @param {string[]} limitedToValues The optional array of allowed values.
* @param {IVariableCallback} callback The callback method to be invoked
* when the Variable is updated.
* @return {ColorVariable}
*/
static addColorVariable(
key: string,
defaultValue: string,
possibleValues?: string[],
limitedToValues?: string[],
callback?: IVariableCallback,
): ColorVariable {
let variable = new ColorVariable(key, defaultValue, possibleValues, callback);
let variable = new ColorVariable(key, defaultValue, limitedToValues, callback);
this.addVariable(variable);
return variable;
}
Expand Down
8 changes: 4 additions & 4 deletions src/core/__tests__/ColorVariable_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe("ColorVariable", () => {
const key: string = "test variable";
const sanitizedKey: string = "test_variable";
const defaultValue: string = "#4285F4";
const possibleValues: string[] = ["#4285F4", "#0F9D58", "#DB4437"];
const limitedToValues: string[] = ["#4285F4", "#0F9D58", "#DB4437"];
let callbackSpy: sinon.SinonSpy;
let variable: ColorVariable;

Expand All @@ -23,7 +23,7 @@ describe("ColorVariable", () => {
variable = remixer.addColorVariable(
key,
defaultValue,
possibleValues,
limitedToValues,
callbackSpy,
);
});
Expand All @@ -48,8 +48,8 @@ describe("ColorVariable", () => {
expect(variable.key).to.equal(sanitizedKey);
});

it("have the correct possible values", () => {
expect(variable.possibleValues).to.equal(possibleValues);
it("have the correct allowed values", () => {
expect(variable.limitedToValues).to.equal(limitedToValues);
});

it("should trigger callback when selected value of variable changes", () => {
Expand Down
8 changes: 4 additions & 4 deletions src/core/__tests__/NumberVariable_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe("NumberVariable", () => {
const key: string = "test variable";
const sanitizedKey: string = "test_variable";
const defaultValue: number = 20;
const possibleValues: number[] = [10, 20, 30, 40];
const limitedToValues: number[] = [10, 20, 30, 40];
let callbackSpy: sinon.SinonSpy;
let variable: NumberVariable;

Expand All @@ -23,7 +23,7 @@ describe("NumberVariable", () => {
variable = remixer.addNumberVariable(
key,
defaultValue,
possibleValues,
limitedToValues,
callbackSpy,
);
});
Expand All @@ -48,8 +48,8 @@ describe("NumberVariable", () => {
expect(variable.key).to.equal(sanitizedKey);
});

it("have the correct possible values", () => {
expect(variable.possibleValues).to.equal(possibleValues);
it("have the correct allowed values", () => {
expect(variable.limitedToValues).to.equal(limitedToValues);
});

it("should trigger callback when selected value of variable changes", () => {
Expand Down
8 changes: 4 additions & 4 deletions src/core/__tests__/StringVariable_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe("StringVariable", () => {
const key: string = "test variable";
const sanitizedKey: string = "test_variable";
const defaultValue: string = "B";
const possibleValues: string[] = ["A", "B", "C", "D"];
const limitedToValues: string[] = ["A", "B", "C", "D"];
let callbackSpy: sinon.SinonSpy;
let variable: StringVariable;

Expand All @@ -23,7 +23,7 @@ describe("StringVariable", () => {
variable = remixer.addStringVariable(
key,
defaultValue,
possibleValues,
limitedToValues,
callbackSpy,
);
});
Expand All @@ -48,8 +48,8 @@ describe("StringVariable", () => {
expect(variable.key).to.equal(sanitizedKey);
});

it("have the correct possible values", () => {
expect(variable.possibleValues).to.equal(possibleValues);
it("have the correct allowed values", () => {
expect(variable.limitedToValues).to.equal(limitedToValues);
});

it("should trigger callback when selected value of variable changes", () => {
Expand Down
20 changes: 10 additions & 10 deletions src/core/variables/ColorVariable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { IVariableCallback, IVariableListParams, Variable } from "./Variable";
interface IColorVariableParams extends IVariableListParams {
defaultValue: string;
selectedValue: string;
possibleValues?: string[];
limitedToValues?: string[];
}

/**
Expand All @@ -42,18 +42,18 @@ export class ColorVariable extends Variable implements IColorVariableParams {
* @constructor
* @param {string} key A unique key for the Variable.
* @param {string} defaultValue The default value.
* @param {string[]} possibleValues The array of possible values.
* @param {string[]} limitedToValues The array of allowed values.
* @param {IVariableCallback} callback The callback to invoke when updated.
* @return {ColorVariable}
*/
constructor(
key: string,
defaultValue: string,
possibleValues?: string[],
limitedToValues?: string[],
callback?: IVariableCallback,
) {
super(key, DataType.COLOR, defaultValue, callback);
this.possibleValues = possibleValues ? possibleValues : [];
this.limitedToValues = limitedToValues ? limitedToValues : [];
}

/**
Expand All @@ -62,7 +62,7 @@ export class ColorVariable extends Variable implements IColorVariableParams {
* @readonly
*/
get constraintType(): string {
return this.possibleValues.length > 0 ?
return this.limitedToValues.length > 0 ?
ConstraintType.LIST : ConstraintType.NONE;
}

Expand All @@ -74,19 +74,19 @@ export class ColorVariable extends Variable implements IColorVariableParams {
let cloned = new ColorVariable(
this.key,
this.defaultValue,
this.possibleValues,
this.limitedToValues,
);
cloned.title = this.title;
cloned._callbacks = this._callbacks.slice();
return cloned;
}

/**
* The array of possible values for this Variable.
* The array of allowed values for this Variable.
* @override
* @type {string[]}
*/
possibleValues?: string[];
limitedToValues?: string[];

/**
* Returns a serialized representation of this object.
Expand All @@ -96,7 +96,7 @@ export class ColorVariable extends Variable implements IColorVariableParams {
serialize(): ISerializableData {
let data = super.serialize();
data.selectedValue = this.selectedValue;
data.possibleValues = this.possibleValues;
data.limitedToValues = this.limitedToValues;
return data;
}

Expand All @@ -107,6 +107,6 @@ export class ColorVariable extends Variable implements IColorVariableParams {
* @return {ColorVariable} A new initialized ColorVariable.
*/
static deserialize(data: ISerializableData): Variable {
return new ColorVariable(data.key, data.selectedValue, data.possibleValues);
return new ColorVariable(data.key, data.selectedValue, data.limitedToValues);
}
}
20 changes: 10 additions & 10 deletions src/core/variables/NumberVariable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { IVariableCallback, IVariableListParams, Variable } from "./Variable";
interface INumberVariableParams extends IVariableListParams {
defaultValue: number;
selectedValue: number;
possibleValues?: number[];
limitedToValues?: number[];
}

/**
Expand All @@ -42,18 +42,18 @@ export class NumberVariable extends Variable implements INumberVariableParams {
* @constructor
* @param {string} key A unique key for the Variable.
* @param {number} defaultValue The default value.
* @param {number[]} possibleValues The array of possible values.
* @param {number[]} limitedToValues The array of allowed values.
* @param {IVariableCallback} callback The callback to invoke when updated.
* @return {NumberVariable}
*/
constructor(
key: string,
defaultValue: number,
possibleValues?: number[],
limitedToValues?: number[],
callback?: IVariableCallback,
) {
super(key, DataType.NUMBER, defaultValue, callback);
this.possibleValues = possibleValues ? possibleValues : [];
this.limitedToValues = limitedToValues ? limitedToValues : [];
}

/**
Expand All @@ -64,7 +64,7 @@ export class NumberVariable extends Variable implements INumberVariableParams {
let cloned = new NumberVariable(
this.key,
this.defaultValue,
this.possibleValues,
this.limitedToValues,
);
cloned.title = this.title;
cloned._callbacks = this._callbacks.slice();
Expand All @@ -77,16 +77,16 @@ export class NumberVariable extends Variable implements INumberVariableParams {
* @readonly
*/
get constraintType(): string {
return this.possibleValues.length > 0 ?
return this.limitedToValues.length > 0 ?
ConstraintType.LIST : ConstraintType.NONE;
}

/**
* The array of possible values for this Variable.
* The array of allowed values for this Variable.
* @override
* @type {number[]}
*/
possibleValues?: number[];
limitedToValues?: number[];

/**
* Returns a serialized representation of this object.
Expand All @@ -96,7 +96,7 @@ export class NumberVariable extends Variable implements INumberVariableParams {
serialize(): ISerializableData {
let data = super.serialize();
data.selectedValue = this.selectedValue;
data.possibleValues = this.possibleValues;
data.limitedToValues = this.limitedToValues;
return data;
}

Expand All @@ -110,7 +110,7 @@ export class NumberVariable extends Variable implements INumberVariableParams {
return new NumberVariable(
data.key,
data.selectedValue,
data.possibleValues,
data.limitedToValues,
);
}
}
Loading

0 comments on commit c795fd8

Please sign in to comment.