mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-19 09:45:37 -04:00
Move lib and test into src directory
Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
241c418ea7
commit
fab2607e4d
98 changed files with 1 additions and 3 deletions
|
@ -1,80 +0,0 @@
|
|||
if (typeof ot === 'undefined') {
|
||||
// Export for browsers
|
||||
var ot = {};
|
||||
}
|
||||
|
||||
ot.WrappedOperation = (function (global) {
|
||||
'use strict';
|
||||
|
||||
// A WrappedOperation contains an operation and corresponing metadata.
|
||||
function WrappedOperation (operation, meta) {
|
||||
this.wrapped = operation;
|
||||
this.meta = meta;
|
||||
}
|
||||
|
||||
WrappedOperation.prototype.apply = function () {
|
||||
return this.wrapped.apply.apply(this.wrapped, arguments);
|
||||
};
|
||||
|
||||
WrappedOperation.prototype.invert = function () {
|
||||
var meta = this.meta;
|
||||
return new WrappedOperation(
|
||||
this.wrapped.invert.apply(this.wrapped, arguments),
|
||||
meta && typeof meta === 'object' && typeof meta.invert === 'function' ?
|
||||
meta.invert.apply(meta, arguments) : meta
|
||||
);
|
||||
};
|
||||
|
||||
// Copy all properties from source to target.
|
||||
function copy (source, target) {
|
||||
for (var key in source) {
|
||||
if (source.hasOwnProperty(key)) {
|
||||
target[key] = source[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function composeMeta (a, b) {
|
||||
if (a && typeof a === 'object') {
|
||||
if (typeof a.compose === 'function') { return a.compose(b); }
|
||||
var meta = {};
|
||||
copy(a, meta);
|
||||
copy(b, meta);
|
||||
return meta;
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
WrappedOperation.prototype.compose = function (other) {
|
||||
return new WrappedOperation(
|
||||
this.wrapped.compose(other.wrapped),
|
||||
composeMeta(this.meta, other.meta)
|
||||
);
|
||||
};
|
||||
|
||||
function transformMeta (meta, operation) {
|
||||
if (meta && typeof meta === 'object') {
|
||||
if (typeof meta.transform === 'function') {
|
||||
return meta.transform(operation);
|
||||
}
|
||||
}
|
||||
return meta;
|
||||
}
|
||||
|
||||
WrappedOperation.transform = function (a, b) {
|
||||
var transform = a.wrapped.constructor.transform;
|
||||
var pair = transform(a.wrapped, b.wrapped);
|
||||
return [
|
||||
new WrappedOperation(pair[0], transformMeta(a.meta, b.wrapped)),
|
||||
new WrappedOperation(pair[1], transformMeta(b.meta, a.wrapped))
|
||||
];
|
||||
};
|
||||
|
||||
return WrappedOperation;
|
||||
|
||||
}(this));
|
||||
|
||||
// Export for CommonJS
|
||||
if (typeof module === 'object') {
|
||||
module.exports = ot.WrappedOperation;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue