Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

quill-delta

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

quill-delta - npm Package Compare versions

Comparing version 3.2.0 to 3.3.0

9

lib/delta.js

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

Delta.prototype.partition = function (predicate) {
var passed = [], failed = [];
this.forEach(function(op) {
var target = predicate(op) ? passed : failed;
target.push(op);
});
return [passed, failed];
};
Delta.prototype.reduce = function (predicate, initial) {

@@ -95,0 +104,0 @@ return this.ops.reduce(predicate, initial);

2

package.json
{
"name": "quill-delta",
"version": "3.2.0",
"version": "3.3.0",
"description": "Format for representing rich text documents and changes.",

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

@@ -81,2 +81,3 @@ # Delta [![Build Status](https://travis-ci.org/quilljs/delta.svg?branch=master)](http://travis-ci.org/quilljs/delta) [![Coverage Status](https://img.shields.io/coveralls/quilljs/delta.svg)](https://coveralls.io/r/quilljs/delta)

- [`map`](#map)
- [`partition`](#partition)
- [`reduce`](#reduce)

@@ -457,2 +458,35 @@ - [`slice`](#slice)

### partition()
Create an array op two arrays, the first with operations that pass the given function, the other that failed.
#### Methods
- `partition(predicate)`
#### Parameters
- `predicate` - Function to call, passing in the current operation, returning whether that operation passed
#### Returns
- `Array` - A new array of two Arrays, the first with passed operations, the other with failed operations
#### Example
```js
var delta = new Delta().insert('Hello', { bold: true })
.insert({ image: 'https://octodex.github.com/images/labtocat.png' })
.insert('World!');
var results = delta.partition(function(op) {
return typeof op.insert === 'string';
});
var passed = results[0]; // [{ insert: 'Hello', attributes: { bold: true }},
{ insert: 'World'}]
var failed = results[1]; // [{ insert: { image: 'https://octodex.github.com/images/labtocat.png' }}]
```
---
### reduce()

@@ -459,0 +493,0 @@

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

});
it('partition()', function () {
var arr = this.delta.partition(function (op) {
return typeof op.insert === 'string';
});
var passed = arr[0], failed = arr[1];
expect(passed).toEqual([this.delta.ops[0], this.delta.ops[2]]);
expect(failed).toEqual([this.delta.ops[1]]);
});
});

@@ -118,0 +127,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc