parse-conflict-json

WebJar for parse-conflict-json

Лицензия

Лицензия

ISC
Категории

Категории

JSON Данные
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

parse-conflict-json
Последняя версия

Последняя версия

1.1.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

parse-conflict-json
WebJar for parse-conflict-json
Ссылка на сайт

Ссылка на сайт

https://www.webjars.org
Система контроля версий

Система контроля версий

https://github.com/npm/parse-conflict-json

Скачать parse-conflict-json

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/parse-conflict-json/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>parse-conflict-json</artifactId>
    <version>1.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/parse-conflict-json/
implementation 'org.webjars.npm:parse-conflict-json:1.1.1'
// https://jarcasting.com/artifacts/org.webjars.npm/parse-conflict-json/
implementation ("org.webjars.npm:parse-conflict-json:1.1.1")
'org.webjars.npm:parse-conflict-json:jar:1.1.1'
<dependency org="org.webjars.npm" name="parse-conflict-json" rev="1.1.1">
  <artifact name="parse-conflict-json" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='parse-conflict-json', version='1.1.1')
)
libraryDependencies += "org.webjars.npm" % "parse-conflict-json" % "1.1.1"
[org.webjars.npm/parse-conflict-json "1.1.1"]

Зависимости

compile (3)

Идентификатор библиотеки Тип Версия
org.webjars.npm : just-diff jar [3.0.1,4)
org.webjars.npm : just-diff-apply jar [3.0.0,4)
org.webjars.npm : json-parse-even-better-errors jar [2.3.0,3)

Модули Проекта

Данный проект не имеет модулей.

parse-conflict-json

Parse a JSON string that has git merge conflicts, resolving if possible.

If the JSON is valid, it just does JSON.parse as normal.

If either side of the conflict is invalid JSON, then an error is thrown for that.

USAGE

// after a git merge that left some conflicts there
const data = fs.readFileSync('package-lock.json', 'utf8')

// reviverFunction is passed to JSON.parse as the reviver function
// preference defaults to 'ours', set to 'theirs' to prefer the other
// side's changes.
const parsed = parseConflictJson(data, reviverFunction, preference)

// returns true if the data looks like a conflicted diff file
parsed.isDiff(data)

Algorithm

If prefer is set to theirs, then the vaules of theirs and ours are switched in the resolver function. (Ie, we'll apply their changes on top of our object, rather than the other way around.)

  • Parse the conflicted file into 3 pieces: ours, theirs, and parent

  • Get the diff from parent to ours.

  • Apply each change of that diff to theirs.

    If any change in the diff set cannot be applied (ie, because they changed an object into a non-object and we changed a field on that object), then replace the object at the specified path with the object at the path in ours.

org.webjars.npm

npm

node package manager

Версии библиотеки

Версия
1.1.1