diff --git a/.gitignore b/.gitignore
index e81a66d..a545ce5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,8 @@
-dist/**
+lib/**
src/**/*.js*
+test/**/*.js
+test/index.html
+test/utils/**
+!test/utils/mocks.ts
node_modules/
npm-debug.log
diff --git a/gulpfile.js b/gulpfile.js
index b13198c..1d0b6b3 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -1,55 +1,5 @@
-const gulp = require("gulp");
-const merge = require("merge2");
-const mochaPhantomJS = require("gulp-mocha-phantomjs");
-const runSequence = require("run-sequence");
-const ts = require("gulp-typescript");
-const tslint = require("gulp-tslint");
-
-gulp.task("tslint", () => {
- return gulp
- .src(["src/**/*.ts", "!src/**/*.d.ts"])
- .pipe(tslint())
- .pipe(tslint.report("verbose"));
-});
-
-gulp.task("tsc", () => {
- const tsProject = ts.createProject("tsconfig.json");
-
- return tsProject
- .src()
- .pipe(ts(tsProject))
- .js.pipe(gulp.dest("src"));
-});
-
-gulp.task("test", () => {
- return gulp
- .src("test/unit/index.html")
- .pipe(mochaPhantomJS());
-
-});
-
-gulp.task("dist", function() {
- const tsProject = ts.createProject(
- "tsconfig.json",
- {
- outFile: "dist/ModAttachr.js",
- removeComments: true
- });
-
- const tsResult = tsProject
- .src()
- .pipe(ts(tsProject));
-
- return merge([
- tsResult.dts.pipe(gulp.dest("dist")),
- tsResult.js.pipe(gulp.dest("dist"))
- ]);
-});
-
-gulp.task("watch", ["default"], () => {
- gulp.watch("src/**/*.ts", ["default"]);
-});
-
-gulp.task("default", ["tsc", "tslint", "dist"], cb => {
- runSequence(["test"], cb);
+require("gulp-shenanigans").initialize({
+ dependencies: ["itemsholdr"],
+ gulp: require("gulp"),
+ packageName: "ModAttachr"
});
diff --git a/package.json b/package.json
index 97320f0..01b19fb 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "modattachr",
"description": "Hookups for extensible triggered mod events.",
- "version": "0.4.0",
+ "version": "0.5.0",
"author": {
"name": "Josh Goldberg",
"email": "josh@fullscreenmario.com"
@@ -15,17 +15,7 @@
},
"license": "MIT",
"devDependencies": {
- "chai": "^3.5.0",
- "gulp": "^3.9.1",
- "gulp-mocha-phantomjs": "^0.11.0",
- "gulp-tslint": "^5.0.0",
- "gulp-typescript": "^2.13.4",
- "merge2": "^1.0.2",
- "mocha": "^2.4.5",
- "requirejs": "^2.2.0",
- "run-sequence": "^1.2.0",
- "tslint": "^3.10.2",
- "typescript": "^1.8.10"
+ "gulp-shenanigans": "^0.3.1"
},
"dependencies": {
"itemsholdr": "^0.4.2"
diff --git a/src/IModAttachr.ts b/src/IModAttachr.ts
index 9555f2d..10f4140 100644
--- a/src/IModAttachr.ts
+++ b/src/IModAttachr.ts
@@ -1,6 +1,4 @@
-///
-
-import { IItemsHoldr } from "IItemsHoldr";
+///
/**
* General schema for a mod, including its name, events with callbacks,
@@ -71,7 +69,7 @@ export interface IModAttachrSettings {
/**
* A ItemsHoldr to store mod status locally.
*/
- ItemsHoldr?: IItemsHoldr;
+ ItemsHoldr?: ItemsHoldr.IItemsHoldr;
/**
* Whether there should be a ItemsHoldr created if one isn't given.
@@ -112,7 +110,7 @@ export interface IModAttachr {
/**
* @returns The ItemsHoldr if storeLocally is true (by default, undefined).
*/
- getItemsHolder(): IItemsHoldr;
+ getItemsHolder(): ItemsHoldr.IItemsHoldr;
/**
* @returns The default scope used to apply mods from, if not this ModAttachr.
diff --git a/src/ModAttachr.ts b/src/ModAttachr.ts
index 1056f3a..f52352f 100644
--- a/src/ModAttachr.ts
+++ b/src/ModAttachr.ts
@@ -1,7 +1,5 @@
-///
+///
-import { IItemsHoldr } from "IItemsHoldr";
-import { ItemsHoldr } from "ItemsHoldr";
import { ICallbackRegister, IEventsRegister, IEventCallback, IMod, IMods, IModAttachr, IModAttachrSettings } from "./IModAttachr";
/**
@@ -21,7 +19,7 @@ export class ModAttachr implements IModAttachr {
/**
* A ItemsHoldr object that may be used to store mod status.
*/
- private ItemsHolder: IItemsHoldr;
+ private ItemsHolder: ItemsHoldr.IItemsHoldr;
/**
* A default scope to apply mod events from, if not this ModAttachr.
@@ -48,7 +46,7 @@ export class ModAttachr implements IModAttachr {
this.ItemsHolder = settings.ItemsHoldr;
} else if (settings.storeLocally) {
// If one isn't provided by storeLocally is still true, make one
- this.ItemsHolder = new ItemsHoldr();
+ this.ItemsHolder = new ItemsHoldr.ItemsHoldr();
}
if (settings.mods) {
@@ -88,7 +86,7 @@ export class ModAttachr implements IModAttachr {
/**
* @returns The ItemsHoldr if storeLocally is true (by default, undefined).
*/
- public getItemsHolder(): IItemsHoldr {
+ public getItemsHolder(): ItemsHoldr.IItemsHoldr {
return this.ItemsHolder;
}
diff --git a/test/ModAttachr/_.ts b/test/ModAttachr/_.ts
new file mode 100644
index 0000000..8005a4d
--- /dev/null
+++ b/test/ModAttachr/_.ts
@@ -0,0 +1,7 @@
+///
+///
+///
+///
+///
+
+mochaLoader.addTest("_", (): void => { });
diff --git a/test/tsconfig.json b/test/tsconfig.json
new file mode 100644
index 0000000..0b4ecd3
--- /dev/null
+++ b/test/tsconfig.json
@@ -0,0 +1,11 @@
+{
+ "compilerOptions": {
+ "target": "es3",
+ "declaration": false
+ },
+ "files": [
+ "utils/mocks.ts",
+ "utils/MochaLoader.ts",
+ "ModAttachr/_.ts"
+ ]
+}
\ No newline at end of file
diff --git a/test/unit/ModAttachrTests/_.js b/test/unit/ModAttachrTests/_.js
deleted file mode 100644
index e5d237b..0000000
--- a/test/unit/ModAttachrTests/_.js
+++ /dev/null
@@ -1,9 +0,0 @@
-define(["mocks"], function (mocks) {
- return function () {
- var expect = require("chai").expect;
-
- it("tests haven't been implemented", function () {
- // ...
- });
- };
-});
\ No newline at end of file
diff --git a/test/unit/index.html b/test/unit/index.html
deleted file mode 100644
index f12d76a..0000000
--- a/test/unit/index.html
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
- EightBittr Unit Tests
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/test/unit/mocks.js b/test/unit/mocks.js
deleted file mode 100644
index 5e88eea..0000000
--- a/test/unit/mocks.js
+++ /dev/null
@@ -1,20 +0,0 @@
-define(["ModAttachr"], function (ModAttachrModule) {
- var ModAttachr = ModAttachrModule.ModAttachr;
-
- var mocks = {
- /**
- *
- */
- mockItemValue: function (settings) {
- return new ItemValue(settings)
- },
- /**
- *
- */
- mockModAttachr: function (settings) {
- return new ModAttachr(settings)
- }
- };
-
- return mocks;
-});
diff --git a/test/unit/phantom.js b/test/unit/phantom.js
deleted file mode 100644
index 7788750..0000000
--- a/test/unit/phantom.js
+++ /dev/null
@@ -1 +0,0 @@
-require(["unit"]);
diff --git a/test/unit/require.js b/test/unit/require.js
deleted file mode 100644
index 93cfe5a..0000000
--- a/test/unit/require.js
+++ /dev/null
@@ -1,5 +0,0 @@
-require(
- ["unit"],
- function () {
- mocha.run();
- });
diff --git a/test/unit/unit.js b/test/unit/unit.js
deleted file mode 100644
index a4fddf4..0000000
--- a/test/unit/unit.js
+++ /dev/null
@@ -1,65 +0,0 @@
-var sources = (function () {
- var config = {
- paths: {
- // Source code
- "ModAttachr": "../../src/ModAttachr",
- // FullScreenShenanigans modules
- "ItemsHoldr": "../../node_modules/itemsholdr/dist/ItemsHoldr",
- // External libraries
- "chai": "../../node_modules/chai/chai"
- }
- };
-
- requirejs.config(config);
-
- return Object.keys(config.paths).concat("mocks");
-})();
-
-var tests = {
- "ModAttachr": [
- "_"
- ]
-};
-
-require(sources, function () {
- var classTests = {};
- var requiredTests = 0;
- var loadedTests = 0;
-
- var runTests = function () {
- mocha.setup("bdd");
-
- for (var className in classTests) {
- describe(className, function () {
- for (var functionName in classTests[className]) {
- describe(functionName, classTests[className][functionName]);
- }
- });
- }
-
- mocha.run();
- };
-
- var generateOnTestLoad = function (className, functionName) {
- requiredTests += 1;
-
- return function (functionTests) {
- classTests[className][functionName] = functionTests;
- loadedTests += 1;
-
- if (loadedTests === requiredTests) {
- runTests();
- }
- }
- }
-
- for (var className in tests) {
- classTests[className] = {};
-
- tests[className].forEach(function (functionName) {
- require(
- [className + "Tests/" + functionName],
- generateOnTestLoad(className, functionName));
- });
- }
-});
\ No newline at end of file
diff --git a/test/utils/mocks.ts b/test/utils/mocks.ts
new file mode 100644
index 0000000..1cea60d
--- /dev/null
+++ b/test/utils/mocks.ts
@@ -0,0 +1,11 @@
+///
+
+const mocks = {
+ /**
+ * @param settings Settings for the ModAttachr.
+ * @returns An ModAttachr instance.
+ */
+ mockModAttachr: (settings?: ModAttachr.IModAttachrSettings): ModAttachr.IModAttachr => {
+ return new ModAttachr.ModAttachr(settings);
+ }
+};
diff --git a/tsconfig.json b/tsconfig.json
index 3660126..f1dd816 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -6,7 +6,8 @@
"declaration": true,
"outDir": "dist"
},
- "exclude": [
- "node_modules"
+ "files": [
+ "src/IModAttachr.ts",
+ "src/ModAttachr.ts"
]
}
\ No newline at end of file
diff --git a/typings/ItemsHoldr.d.ts b/typings/ItemsHoldr.d.ts
new file mode 100644
index 0000000..3227f34
--- /dev/null
+++ b/typings/ItemsHoldr.d.ts
@@ -0,0 +1,773 @@
+declare namespace ItemsHoldr {
+ /**
+ * A container to hold ItemValue objects, keyed by name.
+ */
+ interface IItems {
+ [i: string]: IItemValue;
+ }
+ /**
+ * Settings to initialize a new instance of the IItemsHoldr interface.
+ */
+ interface IItemsHoldrSettings {
+ /**
+ * Initial settings for IItemValues to store.
+ */
+ values?: IItemValueDefaults;
+ /**
+ * Whether new items are allowed to be added (by default, true).
+ */
+ allowNewItems?: boolean;
+ /**
+ * Whether values should be saved immediately upon being set.
+ */
+ autoSave?: boolean;
+ /**
+ * Arguments to pass to triggered callback Functions.
+ */
+ callbackArgs?: any[];
+ /**
+ * A localStorage object to use instead of the global localStorage.
+ */
+ localStorage?: any;
+ /**
+ * A prefix to add before IItemsValue keys
+ */
+ prefix?: string;
+ /**
+ * Default attributes for IItemValues.
+ */
+ defaults?: IItemValueDefaults;
+ /**
+ * Any hardcoded changes to element content.
+ */
+ displayChanges?: {
+ [i: string]: string;
+ };
+ /**
+ * Whether an HTML container should be created to house the IItemValue elements.
+ */
+ doMakeContainer?: boolean;
+ /**
+ * Arguments to pass to create the container, if not the default div and className.
+ */
+ containersArguments?: [string, any][];
+ }
+ /**
+ * A versatile container to store and manipulate values in localStorage, and
+ * optionally keep an updated HTML container showing these values.
+ */
+ interface IItemsHoldr {
+ /**
+ * @returns The values contained within, keyed by their keys.
+ */
+ getValues(): {
+ [i: string]: IItemValue;
+ };
+ /**
+ * @returns Default attributes for values.
+ */
+ getDefaults(): IItemValueDefaults;
+ /**
+ * @returns A reference to localStorage or a replacment object.
+ */
+ getLocalStorage(): Storage;
+ /**
+ * @returns Whether this should save changes to localStorage automatically.
+ */
+ getAutoSave(): boolean;
+ /**
+ * @returns The prefix to store thigns under in localStorage.
+ */
+ getPrefix(): string;
+ /**
+ * @returns The container HTML element, if it exists.
+ */
+ getContainer(): HTMLElement;
+ /**
+ * @returns createElement arguments for HTML containers, outside-to-inside.
+ */
+ getContainersArguments(): [string, any][];
+ /**
+ * @returns Any hard-coded changes to element content.
+ */
+ getDisplayChanges(): {
+ [i: string]: string;
+ };
+ /**
+ * @returns Arguments to be passed to triggered event callbacks.
+ */
+ getCallbackArgs(): any[];
+ /**
+ * @returns String keys for each of the stored IItemValues.
+ */
+ getKeys(): string[];
+ /**
+ * @returns All String keys of items.
+ */
+ getItemKeys(): string[];
+ /**
+ * @param key The key for a known value.
+ * @returns The known value of a key, assuming that key exists.
+ */
+ getItem(key: string): any;
+ /**
+ * @param key The key for a known value.
+ * @returns The settings for that particular key.
+ */
+ getObject(key: string): any;
+ /**
+ * @param key The key for a potentially known value.
+ * @returns Whether there is a value under that key.
+ */
+ hasKey(key: string): boolean;
+ /**
+ * @returns A mapping of key names to the actual values of all objects being stored.
+ */
+ exportItems(): any;
+ /**
+ * Adds a new key & value pair to by linking to a newly created ItemValue.
+ *
+ * @param key The key to reference by new ItemValue by.
+ * @param settings The settings for the new ItemValue.
+ * @returns The newly created ItemValue.
+ */
+ addItem(key: string, settings?: any): IItemValue;
+ /**
+ * Clears a value from the listing, and removes its element from the
+ * container (if they both exist).
+ *
+ * @param key The key of the element to remove.
+ */
+ removeItem(key: string): void;
+ /**
+ * Completely clears all values from the ItemsHoldr, removing their
+ * elements from the container (if they both exist) as well.
+ */
+ clear(): void;
+ /**
+ * Sets the value for the ItemValue under the given key, then updates the ItemValue
+ * (including the ItemValue's element and localStorage, if needed).
+ *
+ * @param key The key of the ItemValue.
+ * @param value The new value for the ItemValue.
+ */
+ setItem(key: string, value: any): void;
+ /**
+ * Increases the value for the ItemValue under the given key, via addition for
+ * Numbers or concatenation for Strings.
+ *
+ * @param key The key of the ItemValue.
+ * @param amount The amount to increase by (by default, 1).
+ */
+ increase(key: string, amount?: number | string): void;
+ /**
+ * Increases the value for the ItemValue under the given key, via addition for
+ * Numbers or concatenation for Strings.
+ *
+ * @param key The key of the ItemValue.
+ * @param amount The amount to increase by (by default, 1).
+ */
+ decrease(key: string, amount?: number): void;
+ /**
+ * Toggles whether a value is true or false.
+ *
+ * @param key The key of the ItemValue.
+ */
+ toggle(key: string): void;
+ /**
+ * Ensures a key exists in values. If it doesn't, and new values are
+ * allowed, it creates it; otherwise, it throws an Error.
+ *
+ * @param key
+ */
+ checkExistence(key: string): void;
+ /**
+ * Manually saves an item's value to localStorage, ignoring the autoSave flag.
+ *
+ * @param key The key of the item to save.
+ */
+ saveItem(key: string): void;
+ /**
+ * Manually saves all values to localStorage, ignoring the autoSave flag.
+ */
+ saveAll(): void;
+ /**
+ * Hides the container Element by setting its visibility to hidden.
+ */
+ hideContainer(): void;
+ /**
+ * Shows the container Element by setting its visibility to visible.
+ */
+ displayContainer(): void;
+ /**
+ * Creates the container Element, which contains a child for each ItemValue that
+ * specifies hasElement to be true.
+ *
+ * @param containers An Array representing the Element to be created and the
+ * children between it and the contained ItemValues.
+ * Each contained Object has a String tag name as its
+ * first member, followed by any number of Objects to apply
+ * via createElement.
+ * @returns A newly created Element that can be used as a container.
+ */
+ makeContainer(containers: [string, any][]): HTMLElement;
+ /**
+ * @returns Whether displayChanges has an entry for a particular value.
+ */
+ hasDisplayChange(value: string): boolean;
+ /**
+ * @returns The displayChanges entry for a particular value.
+ */
+ getDisplayChange(value: string): string;
+ /**
+ * Creates a new HTMLElement of the given type. For each Object given as
+ * arguments after, each member is proliferated onto the element.
+ *
+ * @param tag The type of the HTMLElement (by default, "div").
+ * @param args Any number of Objects to be proliferated onto the
+ * new HTMLElement.
+ * @returns A newly created HTMLElement of the given tag.
+ */
+ createElement(tag?: string, ...args: any[]): HTMLElement;
+ /**
+ * Proliferates all members of the donor to the recipient recursively, as
+ * a deep copy.
+ *
+ * @param recipient An object receiving the donor's members.
+ * @param donor An object whose members are copied to recipient.
+ * @param noOverride If recipient properties may be overriden (by
+ * default, false).
+ * @returns The recipient, which should have the donor proliferated onto it.
+ */
+ proliferate(recipient: any, donor: any, noOverride?: boolean): any;
+ /**
+ * Identical to proliferate, but tailored for HTML elements because many
+ * element attributes don't play nicely with JavaScript Array standards.
+ * Looking at you, HTMLCollection!
+ *
+ * @param recipient An HTMLElement receiving the donor's members.
+ * @param donor An object whose members are copied to recipient.
+ * @param noOverride If recipient properties may be overriden (by
+ * default, false).
+ * @returns The recipient, which should have the donor proliferated onto it.
+ */
+ proliferateElement(recipient: any, donor: any, noOverride?: boolean): any;
+ }
+ /**
+ * A mapping of ItemValue values to triggered callbacks.
+ */
+ interface ITriggers {
+ [i: string]: Function;
+ [j: number]: Function;
+ }
+ /**
+ * A container of default values to pass to IItemValues, keyed by the
+ * IItemValue keys.m
+ */
+ interface IItemValueDefaults {
+ [i: string]: IItemValueSettings;
+ }
+ /**
+ * Settings to initialize a new instance of the IItemValue interface.
+ */
+ interface IItemValueSettings {
+ /**
+ * An initial value to store.
+ */
+ value?: any;
+ /**
+ * A default initial value to store, if value isn't provided.
+ */
+ valueDefault?: any;
+ /**
+ * Whether the value should be stored in the IItemHoldr's localStorage.
+ */
+ storeLocally?: boolean;
+ /**
+ * A mapping of values to callbacks that should be triggered when value
+ * is equal to them.
+ */
+ triggers?: ITriggers;
+ /**
+ * Whether an Element should be created and synced to the value.
+ */
+ hasElement?: boolean;
+ /**
+ * An Element tag to use in creating the element, if hasElement is true.
+ */
+ elementTag?: string;
+ /**
+ * A minimum value for the value to equal, if value is a number.
+ */
+ minimum?: number;
+ /**
+ * A callback to call when the value reaches the minimum value.
+ */
+ onMinimum?: Function;
+ /**
+ * A maximum value for the value to equal, if value is a number.
+ */
+ maximum?: number;
+ /**
+ * A callback to call when the value reaches the maximum value.
+ */
+ onMaximum?: Function;
+ /**
+ * A maximum number to modulo the value against, if value is a number.
+ */
+ modularity?: number;
+ /**
+ * A callback to call when the value reaches modularity.
+ */
+ onModular?: Function;
+ /**
+ * A Function to transform the value when it's being set.
+ */
+ transformGet?: Function;
+ /**
+ * A Function to transform the value when it's being retrieved.
+ */
+ transformSet?: Function;
+ }
+ /**
+ * Storage container for a single IItemsHoldr value. The value may have triggers
+ * assigned to value, modularity, and other triggers, as well as an HTML element.
+ */
+ interface IItemValue {
+ /**
+ * @returns The value being stored, with a transformGet applied if one exists.
+ */
+ getValue(): any;
+ /**
+ * Sets the value being stored, with a is a transformSet applied if one exists.
+ * Any attached triggers to the new value will be called.
+ *
+ * @param value The desired value to now store.
+ */
+ setValue(value: any): void;
+ /**
+ * @returns The stored HTML element, if it exists.
+ */
+ getElement(): HTMLElement;
+ /**
+ * General update Function to be run whenever the internal value is changed.
+ * It runs all the trigger, modular, etc. checks, updates the HTML element
+ * if there is one, and updates localStorage if needed.
+ */
+ update(): void;
+ /**
+ * Stores a ItemValue's value in localStorage under the prefix plus its key.
+ *
+ * @param overrideAutoSave Whether the policy on saving should be ignored
+ * so saving happens regardless. By default, false.
+ */
+ updateLocalStorage(overrideAutoSave?: boolean): void;
+ }
+ /**
+ * A versatile container to store and manipulate values in localStorage, and
+ * optionally keep an updated HTML container showing these values.
+ */
+ class ItemsHoldr implements IItemsHoldr {
+ /**
+ * Settings used to construct this ItemsHoldr.
+ */
+ private settings;
+ /**
+ * The ItemValues being stored, keyed by name.
+ */
+ private items;
+ /**
+ * A listing of all the String keys for the stored items.
+ */
+ private itemKeys;
+ /**
+ * Default attributes for ItemValues.
+ */
+ private defaults;
+ /**
+ * A reference to localStorage or a replacement object.
+ */
+ private localStorage;
+ /**
+ * A prefix to store things under in localStorage.
+ */
+ private prefix;
+ /**
+ * Whether new items are allowed to be created using setItem.
+ */
+ private allowNewItems;
+ /**
+ * Whether this should save changes to localStorage automatically.
+ */
+ private autoSave;
+ /**
+ * A container element containing children for each value's element.
+ */
+ private container;
+ /**
+ * An Array of elements as createElement arguments, outside-to-inside.
+ */
+ private containersArguments;
+ /**
+ * Any hardcoded changes to element content, such as "INF" for Infinity.
+ */
+ private displayChanges;
+ /**
+ * Arguments to be passed to triggered callback Functions.
+ */
+ private callbackArgs;
+ /**
+ * Initializes a new instance of the ItemsHoldr class.
+ *
+ * @param settings Any optional custom settings.
+ */
+ constructor(settings?: IItemsHoldrSettings);
+ /**
+ * @param index An index for a key.
+ * @returns The indexed key.
+ */
+ key(index: number): string;
+ /**
+ * @returns The values contained within, keyed by their keys.
+ */
+ getValues(): {
+ [i: string]: IItemValue;
+ };
+ /**
+ * @returns {Mixed} Default attributes for values.
+ */
+ getDefaults(): any;
+ /**
+ * @returns A reference to localStorage or a replacment object.
+ */
+ getLocalStorage(): Storage;
+ /**
+ * @returns Whether this should save changes to localStorage automatically.
+ */
+ getAutoSave(): boolean;
+ /**
+ * @returns The prefix to store thigns under in localStorage.
+ */
+ getPrefix(): string;
+ /**
+ * @returns The container HTML element, if it exists.
+ */
+ getContainer(): HTMLElement;
+ /**
+ * @returns createElement arguments for HTML containers, outside-to-inside.
+ */
+ getContainersArguments(): [string, any][];
+ /**
+ * @returns Any hard-coded changes to element content.
+ */
+ getDisplayChanges(): {
+ [i: string]: string;
+ };
+ /**
+ * @returns Arguments to be passed to triggered event callbacks.
+ */
+ getCallbackArgs(): any[];
+ /**
+ * @returns String keys for each of the stored ItemValues.
+ */
+ getKeys(): string[];
+ /**
+ * @returns All String keys of items.
+ */
+ getItemKeys(): string[];
+ /**
+ * @param key The key for a known value.
+ * @returns The known value of a key, assuming that key exists.
+ */
+ getItem(key: string): any;
+ /**
+ * @param key The key for a known value.
+ * @returns The settings for that particular key.
+ */
+ getObject(key: string): any;
+ /**
+ * @param key The key for a potentially known value.
+ * @returns Whether there is a value under that key.
+ */
+ hasKey(key: string): boolean;
+ /**
+ * @returns A mapping of key names to the actual values of all objects being stored.
+ */
+ exportItems(): any;
+ /**
+ * Adds a new key & value pair to by linking to a newly created ItemValue.
+ *
+ * @param key The key to reference by new ItemValue by.
+ * @param settings The settings for the new ItemValue.
+ * @returns The newly created ItemValue.
+ */
+ addItem(key: string, settings?: any): IItemValue;
+ /**
+ * Clears a value from the listing, and removes its element from the
+ * container (if they both exist).
+ *
+ * @param key The key of the element to remove.
+ */
+ removeItem(key: string): void;
+ /**
+ * Completely clears all values from the ItemsHoldr, removing their
+ * elements from the container (if they both exist) as well.
+ */
+ clear(): void;
+ /**
+ * Sets the value for the ItemValue under the given key, then updates the ItemValue
+ * (including the ItemValue's element and localStorage, if needed).
+ *
+ * @param key The key of the ItemValue.
+ * @param value The new value for the ItemValue.
+ */
+ setItem(key: string, value: any): void;
+ /**
+ * Increases the value for the ItemValue under the given key, via addition for
+ * Numbers or concatenation for Strings.
+ *
+ * @param key The key of the ItemValue.
+ * @param amount The amount to increase by (by default, 1).
+ */
+ increase(key: string, amount?: number | string): void;
+ /**
+ * Decreases the value for the ItemValue under the given key, via addition for
+ * Numbers or concatenation for Strings.
+ *
+ * @param key The key of the ItemValue.
+ * @param amount The amount to decrease by (by default, 1).
+ */
+ decrease(key: string, amount?: number): void;
+ /**
+ * Toggles whether a value is true or false.
+ *
+ * @param key The key of the ItemValue.
+ */
+ toggle(key: string): void;
+ /**
+ * Ensures a key exists in values. If it doesn't, and new values are
+ * allowed, it creates it; otherwise, it throws an Error.
+ *
+ * @param key
+ */
+ checkExistence(key: string): void;
+ /**
+ * Manually saves an item's value to localStorage, ignoring the autoSave flag.
+ *
+ * @param key The key of the item to save.
+ */
+ saveItem(key: string): void;
+ /**
+ * Manually saves all values to localStorage, ignoring the autoSave flag.
+ */
+ saveAll(): void;
+ /**
+ * Hides the container Element by setting its visibility to hidden.
+ */
+ hideContainer(): void;
+ /**
+ * Shows the container Element by setting its visibility to visible.
+ */
+ displayContainer(): void;
+ /**
+ * Creates the container Element, which contains a child for each ItemValue that
+ * specifies hasElement to be true.
+ *
+ * @param containers An Array representing the Element to be created and the
+ * children between it and the contained ItemValues.
+ * Each contained Object has a String tag name as its
+ * first member, followed by any number of Objects to apply
+ * via createElement.
+ * @returns A newly created Element that can be used as a container.
+ */
+ makeContainer(containers: [string, any][]): HTMLElement;
+ /**
+ * @returns Whether displayChanges has an entry for a particular value.
+ */
+ hasDisplayChange(value: string): boolean;
+ /**
+ * @returns The displayChanges entry for a particular value.
+ */
+ getDisplayChange(value: string): string;
+ /**
+ * Creates a new HTMLElement of the given type. For each Object given as
+ * arguments after, each member is proliferated onto the element.
+ *
+ * @param tag The type of the HTMLElement (by default, "div").
+ * @param args Any number of Objects to be proliferated onto the
+ * new HTMLElement.
+ * @returns A newly created HTMLElement of the given tag.
+ */
+ createElement(tag?: string, ...args: any[]): HTMLElement;
+ /**
+ * Proliferates all members of the donor to the recipient recursively, as
+ * a deep copy.
+ *
+ * @param recipient An object receiving the donor's members.
+ * @param donor An object whose members are copied to recipient.
+ * @param noOverride If recipient properties may be overriden (by
+ * default, false).
+ * @returns The recipient, which should have the donor proliferated onto it.
+ */
+ proliferate(recipient: any, donor: any, noOverride?: boolean): any;
+ /**
+ * Identical to proliferate, but tailored for HTML elements because many
+ * element attributes don't play nicely with JavaScript Array standards.
+ * Looking at you, HTMLCollection!
+ *
+ * @param recipient An HTMLElement receiving the donor's members.
+ * @param donor An object whose members are copied to recipient.
+ * @param noOverride If recipient properties may be overriden (by
+ * default, false).
+ * @returns The recipient, which should have the donor proliferated onto it.
+ */
+ proliferateElement(recipient: any, donor: any, noOverride?: boolean): HTMLElement;
+ /**
+ * Creates an Object that can be used to create a new LocalStorage
+ * replacement, if the JavaScript environment doesn't have one.
+ *
+ * @returns {Object}
+ */
+ private createPlaceholderStorage();
+ /**
+ * Resets this.items to their default values and resets this.itemKeys.
+ */
+ private resetItemsToDefaults();
+ }
+ /**
+ * Storage container for a single ItemsHoldr value. The value may have triggers
+ * assigned to value, modularity, and other triggers, as well as an HTML element.
+ */
+ class ItemValue implements IItemValue {
+ /**
+ * The container ItemsHoldr governing usage of this ItemsValue.
+ */
+ private ItemsHolder;
+ /**
+ * The unique key identifying this ItemValue in the ItemsHoldr.
+ */
+ private key;
+ /**
+ * A default initial value to store, if value isn't provided.
+ */
+ private valueDefault;
+ /**
+ * Whether the value should be stored in the ItemHoldr's localStorage.
+ */
+ private storeLocally;
+ /**
+ * A mapping of values to callbacks that should be triggered when value
+ * is equal to them.
+ */
+ private triggers;
+ /**
+ * An HTML element whose second child's textContent is always set to that of the element.
+ */
+ private element;
+ /**
+ * Whether an Element should be created and synced to the value.
+ */
+ private hasElement;
+ /**
+ * An Element tag to use in creating the element, if hasElement is true.
+ */
+ private elementTag;
+ /**
+ * A minimum value for the value to equal, if value is a number.
+ */
+ private minimum;
+ /**
+ * A callback to call when the value reaches the minimum value.
+ */
+ private onMinimum;
+ /**
+ * A maximum value for the value to equal, if value is a number.
+ */
+ private maximum;
+ /**
+ * A callback to call when the value reaches the maximum value.
+ */
+ private onMaximum;
+ /**
+ * A maximum number to modulo the value against, if value is a number.
+ */
+ private modularity;
+ /**
+ * A callback to call when the value reaches modularity.
+ */
+ private onModular;
+ /**
+ * A Function to transform the value when it's being set.
+ */
+ private transformGet;
+ /**
+ * A Function to transform the value when it's being retrieved.
+ */
+ private transformSet;
+ /**
+ * The value being stored.
+ */
+ private value;
+ /**
+ * Creates a new ItemValue with the given key and settings. Defaults are given
+ * to the value via proliferate before the settings.
+ *
+ * @constructor
+ * @param ItemsHolder The container for this value.
+ * @param key The key to reference this new ItemValue by.
+ * @param settings Any optional custom settings.
+ */
+ constructor(ItemsHolder: IItemsHoldr, key: string, settings?: any);
+ /**
+ * @returns The value being stored, with a transformGet applied if one exists.
+ */
+ getValue(): any;
+ /**
+ * Sets the value being stored, with a is a transformSet applied if one exists.
+ * Any attached triggers to the new value will be called.
+ *
+ * @param value The desired value to now store.
+ */
+ setValue(value: any): void;
+ /**
+ * @returns The stored HTML element, if it exists.
+ */
+ getElement(): HTMLElement;
+ /**
+ * General update Function to be run whenever the internal value is changed.
+ * It runs all the trigger, modular, etc. checks, updates the HTML element
+ * if there is one, and updates localStorage if needed.
+ */
+ update(): void;
+ /**
+ * Stores a ItemValue's value in localStorage under the prefix plus its key.
+ *
+ * @param [overrideAutoSave] Whether the policy on saving should be
+ * ignored (so saving happens regardless). By
+ * default, false.
+ */
+ updateLocalStorage(overrideAutoSave?: boolean): void;
+ /**
+ * Checks if the current value should trigger a callback, and if so calls it.
+ */
+ private checkTriggers();
+ /**
+ * Checks if the current value is greater than the modularity (assuming
+ * modular is a non-zero Numbers), and if so, continuously reduces value and
+ * calls this.onModular.
+ */
+ private checkModularity();
+ /**
+ * Updates the ItemValue's element's second child to be the ItemValue's value.
+ */
+ private updateElement();
+ /**
+ * Retrieves a ItemValue's value from localStorage, making sure not to try to
+ * JSON.parse an undefined or null value.
+ *
+ * @returns {Mixed}
+ */
+ private retrieveLocalStorage();
+ }
+}
+declare var module: any;