Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@kizahasi/ot-string
Advanced tools
Operational Transfomation library for string.
Run npm install @kizahasi/ot-string
or yarn add @kizahasi/ot-string
import { TextTwoWayOperation, TextUpOperation, TextDownOperation } from '@kizahasi/ot-string';
// Gets diff of two string (diff-match-patch is used)
const twoWayOperation: TextTwoWayOperation.Operation = TextTwoWayOperation.diff(
{
first: 'Roses are red',
second: 'Violets are blue',
}
);
const upOperation: TextUpOperation.Operation = TextTwoWayOperation.toUpOperation(
twoWayOperation
);
const second = TextUpOperation.apply({
prevState: 'Roses are red',
action: upOperation,
});
/* second =
{ isError: false, value: 'Violets are blue' }
*/
const downOperation: TextDownOperation.Operation = TextTwoWayOperation.toDownOperation(
twoWayOperation
);
const first = TextDownOperation.applyBack({
nextState: 'Violets are blue',
action: downOperation,
});
/* first =
{ isError: false, value: 'Roses are red' }
*/
// If you want to serialize a Text(Up|Down)Operation.Operation object, Text(Up|Down)Operation.toUpUnit helps you.
// (t = type, r = retain, i = insert, d = delete)
const upOperationAsUnitArray = TextUpOperation.toUnit(upOperation);
/* upOperationAsUnitArray =
[
{ t: 'd', d: 1 },
{ t: 'i', i: 'Vi' },
{ t: 'r', r: 1 },
{ t: 'd', d: 1 },
{ t: 'i', i: 'l' },
{ t: 'r', r: 1 },
{ t: 'i', i: 't' },
{ t: 'r', r: 6 },
{ t: 'd', d: 1 },
{ t: 'i', i: 'blu' },
{ t: 'r', r: 1 },
{ t: 'd', d: 1 }
]
*/
const downOperationAsUnitArray = TextDownOperation.toUnit(downOperation);
/* downOperationAsUnitArray =
[
{ t: 'd', d: 'R' },
{ t: 'i', i: 2 },
{ t: 'r', r: 1 },
{ t: 'd', d: 's' },
{ t: 'i', i: 1 },
{ t: 'r', r: 1 },
{ t: 'i', i: 1 },
{ t: 'r', r: 6 },
{ t: 'd', d: 'r' },
{ t: 'i', i: 3 },
{ t: 'r', r: 1 },
{ t: 'd', d: 'd' }
]
*/
// To convert back to Text(Up|Down)Operation.Operation, use ofUnit.
const upOperation2 = TextUpOperation.ofUnit(upOperationAsUnitArray);
// upOperation2 equals to upOperation
const downOperation2 = TextDownOperation.ofUnit(downOperationAsUnitArray);
// downOperation2 equals to downOperation
FAQs
Operational Transfomation library for string
The npm package @kizahasi/ot-string receives a total of 432 weekly downloads. As such, @kizahasi/ot-string popularity was classified as not popular.
We found that @kizahasi/ot-string demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.