-
Notifications
You must be signed in to change notification settings - Fork 450
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #217 from Teamwork/fix-op-validation
Allow op to be a non-object
- Loading branch information
Showing
3 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// A simple number type, where: | ||
// | ||
// - snapshot is an integer | ||
// - operation is an integer | ||
exports.type = { | ||
name: 'number-type', | ||
uri: 'http://sharejs.org/types/number-type', | ||
create: create, | ||
apply: apply, | ||
transform: transform | ||
}; | ||
|
||
function create(data) { | ||
return data | 0; | ||
} | ||
|
||
function apply(snapshot, op) { | ||
return snapshot + op; | ||
} | ||
|
||
function transform(op1, op2, side) { | ||
return op1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters