1 Star 0 Fork 0

Onesimu/diff

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
diff.js 1.09 KB
一键复制 编辑 原始数据 按行查看 历史
Onesimu 提交于 2022-12-29 14:42 . word
// const myers = require('myers-diff');
const myers = require('./src/');
const fs = require('fs')
// const lhs = fs.readFileSync('./tmp/outen.md', {encoding:'utf8', flag:'r'})
// const rhs = fs.readFileSync('./tmp/su.txt', {encoding:'utf8', flag:'r'})
const lhs = fs.readFileSync('./tmp/out.md', {encoding:'utf8', flag:'r'})
const rhs = fs.readFileSync('./tmp/br.txt', {encoding:'utf8', flag:'r'})
const diff = myers.diff(lhs, rhs, {
// compare: 'chars',
compare: 'words',
ignoreWhitespace: true,
ignoreCase: true,
ignoreAccents: true,
ignorePunctuation: true
})
console.log(myers.formats.GnuNormalFormat(diff));
// console.log(diff);
// const str = ''
// const segmenterJa = new Intl.Segmenter('zh-CN', { granularity: 'word' })
// const segments = segmenterJa.segment(str)
// console.table(Array.from(segments));
// const str = 'We believed in Jesus Christ, who died for us sins, who rose again.'
// const segmenterJa = new Intl.Segmenter('en-US', { granularity: 'word' })
// const segments = segmenterJa.segment(str)
// console.table(Array.from(segments).filter(it => it.isWordLike));
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Onesimu/diff.git
git@gitee.com:Onesimu/diff.git
Onesimu
diff
diff
master

搜索帮助