[feat] update

This commit is contained in:
Jay 2020-09-14 16:01:08 +08:00
parent 0dbb651a74
commit f9eb20cfe9
3 changed files with 26 additions and 14 deletions

View File

@ -1,5 +1,5 @@
[package]
name = "node-rs-diff"
name = "rsdiff"
version = "0.1.0"
authors = ["Jay <jay@trj.tw>"]
edition = "2018"
@ -7,6 +7,7 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
name = "rsdiff"
crate-type = ["cdylib"]
[dependencies]

View File

@ -1,14 +1,25 @@
const test = require('ava')
const test = require("ava");
const { diffChars } = require('../index')
const { diffChars, diffLines } = require("../index");
test('diff chars', (t) => {
const left = 'asd'
const right = 'asd'
const result = diffChars(left, right)
t.is(result.length, 1)
t.is(result[0].count, 3)
t.is(result[0].value, 'asd')
t.is(result[0].added, false)
t.is(result[0].removed, false)
})
test("diff chars", (t) => {
const left = "asd";
const right = "asd";
const result = diffChars(left, right);
t.is(result.length, 1);
t.is(result[0].count, 3);
t.is(result[0].value, "asd");
t.is(result[0].added, false);
t.is(result[0].removed, false);
});
test("diff lines", (t) => {
const left = "asd\ndsa";
const right = "asd\nddd\nvvv\n\na";
const result = diffLines(left, right);
t.is(result.length, 3);
t.is(result[0].count, 1);
t.is(result[1].count, 1);
t.is(result[2].count, 4);
});

View File

@ -30,7 +30,7 @@
"node": ">= 8.9"
},
"scripts": {
"build": "cargo build --release && napi build --platform --release .",
"build": "cargo build --release && napi build --platform --release",
"build:debug": "cargo build && napi build --platform .",
"test": "ava",
"publish:linux": "cross-env PLATFORM=linux node scripts/publish.js",