Skip to content

Commit

Permalink
Merge pull request #6 from Palindrom/nodify-and-publish
Browse files Browse the repository at this point in the history
Support Node imports
  • Loading branch information
alshakero authored Mar 9, 2017
2 parents 9e47779 + 1d20c41 commit 61992ac
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 15 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Node.js
node_modules/*
npm-debug.log
*.log

# WebStorm
.idea
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: node_js
sudo: required
dist: trusty
before_script:
- npm install
- 'export PATH=$PWD/node_modules/.bin:$PATH'
node_js: 6
script:
- xvfb-run npm run test
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ Separated demo will be provided soon.

## Install

Install the component using NPM

```sh
$ npm install json-patch-ot --save
```

Or

Install the component using [Bower](http://bower.io/):

```sh
Expand Down
3 changes: 1 addition & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
"node_modules",
"bower_components",
"test",
"tests",
"gruntfile.js"
"tests"
],
"devDependencies": {
}
Expand Down
2 changes: 2 additions & 0 deletions dist/json-patch-ot.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/json-patch-ot.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = function(grunt) {
{
expand: true, // Enable dynamic expansion.
cwd: 'src/', // Src matches are relative to this path.
src: ['json-patch-queue.js'], // Actual pattern(s) to match.
src: ['json-patch-ot.js'], // Actual pattern(s) to match.
dest: 'dist/', // Destination path prefix.
ext: '.min.js', // Dest filepaths will have this extension.
extDot: 'first' // Extensions in filenames begin after the first dot
Expand All @@ -25,10 +25,10 @@ module.exports = function(grunt) {
},
bump: {
options: {
files: ['package.json', 'bower.json'],
files: ['package.json', 'bower.json', 'src/*'],
commit: true,
commitMessage: '%VERSION%',
commitFiles: ['package.json', 'bower.json'],
commitFiles: ['package.json', 'bower.json', 'index.d.ts', 'src/*'],
createTag: true,
tagName: '%VERSION%',
tagMessage: 'Version %VERSION%',
Expand All @@ -42,4 +42,4 @@ module.exports = function(grunt) {
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-bump');
};
};
11 changes: 11 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*!
* https://github.com/Palindrom/JSONPatchOT
* JSON-Patch-OT version: 1.0.1
* (c) 2017 Tomek Wytrebowicz
* MIT license
*/
declare class JSONPatchOT {
public static transform(patch: Object, sequences: Array<Object>);
public static transformAgainstSingleOp(patch: Object, operationObject: Object);
}
export default JSONPatchOT;
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
"version": "1.0.1",
"description": "JSON Patch Operational Transformations - resolves outdated JSON Patches (RFC6902) in real-time JSON collaboration",
"main": "src/json-patch-ot.js",
"typings": "index.d.ts",
"scripts": {
"test": "jasmine-node --matchall --config test/spec/coreSpec.js"
"test": "jasmine-node --matchall test/spec/transformSpec.js"
},
"repository": {
"type": "git",
Expand All @@ -28,8 +29,9 @@
"node": ">= 0.4.0"
},
"devDependencies": {
"grunt": "^0.4.5",
"grunt-bump": "^0.6.0",
"grunt-contrib-uglify": "~0.5.0"
"grunt": "^1.0.1",
"grunt-bump": "^0.8.0",
"grunt-contrib-uglify": "^2.2.0",
"jasmine-node": "^1.14.5"
}
}
23 changes: 18 additions & 5 deletions src/json-patch-ot.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
(function(scope){
var debug = false;
/*!
* https://github.com/Palindrom/JSONPatchOT
* JSON-Patch-OT version: 1.0.1
* (c) 2017 Tomek Wytrebowicz
* MIT license
*/

var JSONPatchOT = (function(){

var JSONPatchOT = scope.JSONPatchOT || {};
var debug = false;
var JSONPatchOT = JSONPatchOT || {};
JSONPatchOT.transform = function (sequenceA, sequences) {
var concatAllSequences = [];
concatAllSequences = concatAllSequences.concat.apply(concatAllSequences, sequences);
Expand Down Expand Up @@ -139,5 +146,11 @@
var n = ~~Number(str);
return String(n) === str && n >= 0;
}
scope.JSONPatchOT = JSONPatchOT;
}(window));
return JSONPatchOT;
}());

if(typeof module !== 'undefined') {
module.exports = JSONPatchOT;
module.exports.default = JSONPatchOT;
module.exports.__esModule = true;
}
33 changes: 33 additions & 0 deletions test/SpecRunnerMin.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Jasmine Spec Runner v2.1.3</title>

<link rel="shortcut icon" type="image/png" href="lib/jasmine-2.1.3/jasmine_favicon.png">
<link rel="stylesheet" href="lib/jasmine-2.1.3/jasmine.css">

<script src="lib/jasmine-2.1.3/jasmine.js"></script>
<script src="lib/jasmine-2.1.3/jasmine-html.js"></script>
<script src="lib/jasmine-2.1.3/boot.js"></script>


<!-- include Benchmark.js -->
<script src="lib/benchmark.js/vendor/lodash/dist/lodash.compat.js"></script>
<script src="lib/benchmark.js/vendor/platform.js/platform.js"></script>
<script src="lib/benchmark.js/benchmark.js"></script>
<script src="lib/benchmark_reporter.js"></script>
<link rel="stylesheet" type="text/css" href="lib/benchmark_reporter.css">

<!-- include source files here... -->
<script src="../dist/json-patch-ot.min.js"></script>

<!-- include spec files here... -->
<script src="spec/transformSpec.js"></script>


</head>

<body>
</body>
</html>
3 changes: 3 additions & 0 deletions test/spec/transformSpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
var obj;

if(typeof JSONPatchOT === 'undefined') {
JSONPatchOT = require('../../src/json-patch-ot');
}
describe("JSONPatchOT when `.transform`s", function(){

describe("given JSON Patch sequence, and", function(){
Expand Down

0 comments on commit 61992ac

Please sign in to comment.