character-sheet
Version:
CharacterSheet library for assembling relationships between stats and modifiers.
103 lines (75 loc) • 2.39 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: operations/Add.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: operations/Add.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>import RegisterWith from './util/RegisterWith';
import Operation from '../Operation';
/**
* Transform the value by adding to it.
*/
class Add extends Operation {
/**
* @static
* @param type {String}
*/
static type = 'add';
_value = null;
/**
* @constructor
* @param {Object} Settings Configuration for the operation.
* @param {String | Number} Settings.value Adds a number or the calculated value of another selector
*/
constructor({ value = null }) {
super(...arguments);
this._value = value;
}
static from(addOperation) {
let o = new Add({ value: addOperation.value });
return o;
}
import(addOperation) {
this._value = addOperation.value;
}
export() {
return {
type: Add.type,
value: this._value
};
}
transform(value, resolver) {
if (typeof this._value === 'string') {
return value + resolver(this._value);
}
return value + this._value;
}
}
export default RegisterWith(Operation)(Add);
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Add.html">Add</a></li><li><a href="Modifier.html">Modifier</a></li><li><a href="Operation.html">Operation</a></li><li><a href="Using.html">Using</a></li></ul><h3>Global</h3><ul><li><a href="global.html#RegisterWith">RegisterWith</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Dec 25 2018 11:17:38 GMT-0800 (Pacific Standard Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>