Skip to content

Commit 61992ac

Browse files
authored
Merge pull request #6 from Palindrom/nodify-and-publish
Support Node imports
2 parents 9e47779 + 1d20c41 commit 61992ac

12 files changed

+97
-15
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# Node.js
55
node_modules/*
66
npm-debug.log
7+
*.log
78

89
# WebStorm
910
.idea

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
language: node_js
2+
sudo: required
3+
dist: trusty
4+
before_script:
5+
- npm install
6+
- 'export PATH=$PWD/node_modules/.bin:$PATH'
7+
node_js: 6
8+
script:
9+
- xvfb-run npm run test

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ Separated demo will be provided soon.
1212

1313
## Install
1414

15+
Install the component using NPM
16+
17+
```sh
18+
$ npm install json-patch-ot --save
19+
```
20+
21+
Or
22+
1523
Install the component using [Bower](http://bower.io/):
1624

1725
```sh

bower.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
"node_modules",
2222
"bower_components",
2323
"test",
24-
"tests",
25-
"gruntfile.js"
24+
"tests"
2625
],
2726
"devDependencies": {
2827
}

dist/json-patch-ot.min.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/json-patch-ot.min.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gruntfile.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = function(grunt) {
1515
{
1616
expand: true, // Enable dynamic expansion.
1717
cwd: 'src/', // Src matches are relative to this path.
18-
src: ['json-patch-queue.js'], // Actual pattern(s) to match.
18+
src: ['json-patch-ot.js'], // Actual pattern(s) to match.
1919
dest: 'dist/', // Destination path prefix.
2020
ext: '.min.js', // Dest filepaths will have this extension.
2121
extDot: 'first' // Extensions in filenames begin after the first dot
@@ -25,10 +25,10 @@ module.exports = function(grunt) {
2525
},
2626
bump: {
2727
options: {
28-
files: ['package.json', 'bower.json'],
28+
files: ['package.json', 'bower.json', 'src/*'],
2929
commit: true,
3030
commitMessage: '%VERSION%',
31-
commitFiles: ['package.json', 'bower.json'],
31+
commitFiles: ['package.json', 'bower.json', 'index.d.ts', 'src/*'],
3232
createTag: true,
3333
tagName: '%VERSION%',
3434
tagMessage: 'Version %VERSION%',
@@ -42,4 +42,4 @@ module.exports = function(grunt) {
4242
});
4343
grunt.loadNpmTasks('grunt-contrib-uglify');
4444
grunt.loadNpmTasks('grunt-bump');
45-
};
45+
};

index.d.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*!
2+
* https://github.com/Palindrom/JSONPatchOT
3+
* JSON-Patch-OT version: 1.0.1
4+
* (c) 2017 Tomek Wytrebowicz
5+
* MIT license
6+
*/
7+
declare class JSONPatchOT {
8+
public static transform(patch: Object, sequences: Array<Object>);
9+
public static transformAgainstSingleOp(patch: Object, operationObject: Object);
10+
}
11+
export default JSONPatchOT;

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
"version": "1.0.1",
44
"description": "JSON Patch Operational Transformations - resolves outdated JSON Patches (RFC6902) in real-time JSON collaboration",
55
"main": "src/json-patch-ot.js",
6+
"typings": "index.d.ts",
67
"scripts": {
7-
"test": "jasmine-node --matchall --config test/spec/coreSpec.js"
8+
"test": "jasmine-node --matchall test/spec/transformSpec.js"
89
},
910
"repository": {
1011
"type": "git",
@@ -28,8 +29,9 @@
2829
"node": ">= 0.4.0"
2930
},
3031
"devDependencies": {
31-
"grunt": "^0.4.5",
32-
"grunt-bump": "^0.6.0",
33-
"grunt-contrib-uglify": "~0.5.0"
32+
"grunt": "^1.0.1",
33+
"grunt-bump": "^0.8.0",
34+
"grunt-contrib-uglify": "^2.2.0",
35+
"jasmine-node": "^1.14.5"
3436
}
3537
}

src/json-patch-ot.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
(function(scope){
2-
var debug = false;
1+
/*!
2+
* https://github.com/Palindrom/JSONPatchOT
3+
* JSON-Patch-OT version: 1.0.1
4+
* (c) 2017 Tomek Wytrebowicz
5+
* MIT license
6+
*/
7+
8+
var JSONPatchOT = (function(){
39

4-
var JSONPatchOT = scope.JSONPatchOT || {};
10+
var debug = false;
11+
var JSONPatchOT = JSONPatchOT || {};
512
JSONPatchOT.transform = function (sequenceA, sequences) {
613
var concatAllSequences = [];
714
concatAllSequences = concatAllSequences.concat.apply(concatAllSequences, sequences);
@@ -139,5 +146,11 @@
139146
var n = ~~Number(str);
140147
return String(n) === str && n >= 0;
141148
}
142-
scope.JSONPatchOT = JSONPatchOT;
143-
}(window));
149+
return JSONPatchOT;
150+
}());
151+
152+
if(typeof module !== 'undefined') {
153+
module.exports = JSONPatchOT;
154+
module.exports.default = JSONPatchOT;
155+
module.exports.__esModule = true;
156+
}

0 commit comments

Comments
 (0)