Socket
Socket
Sign inDemoInstall

rich-text

Package Overview
Dependencies
1
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0 to 2.1.0

10

CHANGELOG.md

@@ -0,5 +1,13 @@

## v2.1.0
#### Features
- Add `concat()` method for document Deltas
## v2.0.0
Changes:
#### Breaking Changes
- `compose()` returns a new Delta instead of self-modifying
#### Features
- Support embed being any non-string type

@@ -148,2 +148,11 @@ var diff = require('fast-diff');

Delta.prototype.concat = function (other) {
var delta = this.slice();
if (other.ops.length > 0) {
delta.push(other.ops[0]);
delta.ops = delta.ops.concat(other.ops.slice(1));
}
return delta;
};
Delta.prototype.diff = function (other) {

@@ -150,0 +159,0 @@ var delta = new Delta();

2

package.json
{
"name": "rich-text",
"version": "2.0.0",
"version": "2.1.0",
"description": "Format for representing rich text documents and changes.",

@@ -5,0 +5,0 @@ "author": "Jason Chen <jhchen7@gmail.com>",

@@ -372,2 +372,36 @@ # Rich Text [![Build Status](https://travis-ci.org/ottypes/rich-text.svg?branch=master)](http://travis-ci.org/ottypes/rich-text) [![Coverage Status](https://img.shields.io/coveralls/ottypes/rich-text.svg)](https://coveralls.io/r/ottypes/rich-text)

### concat()
Returns a new Delta representing the concatenation of this and another document Delta's operations.
#### Methods
- `concat(other)`
#### Parameters
- `other` - Document Delta to concatenate
#### Returns
- `Delta` - Concatenated document Delta
#### Example
```js
var a = new Delta().insert('Hello');
var b = new Delta().insert('!', { bold: true });
// {
// ops: [
// { insert: 'Hello' },
// { insert: '!', attributes: { bold: true } }
// ]
// }
var concat = a.concat(b);
```
---
### diff()

@@ -374,0 +408,0 @@

@@ -6,2 +6,25 @@ var Delta = require('../../lib/delta');

describe('helpers', function () {
describe('concat()', function () {
it('empty delta', function () {
var delta = new Delta().insert('Test');
var concat = new Delta();
var expected = new Delta().insert('Test');
expect(delta.concat(concat)).to.deep.equal(expected);
});
it('unmergeable', function () {
var delta = new Delta().insert('Test');
var concat = new Delta().insert('!', { bold: true });
var expected = new Delta().insert('Test').insert('!', { bold: true });
expect(delta.concat(concat)).to.deep.equal(expected);
});
it('mergeable', function () {
var delta = new Delta().insert('Test', { bold: true });
var concat = new Delta().insert('!', { bold: true }).insert('\n');
var expected = new Delta().insert('Test!', { bold: true }).insert('\n');
expect(delta.concat(concat)).to.deep.equal(expected);
});
});
describe('chop()', function () {

@@ -8,0 +31,0 @@ it('retain', function () {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc