New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ezs/basics

Package Overview
Dependencies
Maintainers
3
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ezs/basics - npm Package Compare versions

Comparing version 1.24.0 to 2.0.0

17

CHANGELOG.md

@@ -6,2 +6,19 @@ # Change Log

# [2.0.0](https://github.com/Inist-CNRS/ezs/compare/@ezs/basics@1.24.0...@ezs/basics@2.0.0) (2023-03-29)
### Features
* **basics:** Make TXTSentences pass some tests ([95bd41f](https://github.com/Inist-CNRS/ezs/commit/95bd41f836e5ee2f71c8413142df9ac4dd9ec84b))
* **basics:** Make TXTSentences work with arrays too ([24c3f76](https://github.com/Inist-CNRS/ezs/commit/24c3f76be73a518791e59b7e78c4d1151af8edd6))
### BREAKING CHANGES
* **basics:** TXTSentences xxpected structure is now an object, with a value key.
# [1.24.0](https://github.com/Inist-CNRS/ezs/compare/@ezs/basics@1.23.5...@ezs/basics@1.24.0) (2023-03-28)

@@ -8,0 +25,0 @@

42

lib/txt-sentences.js

@@ -8,4 +8,6 @@ "use strict";

var _string_decoder = require("string_decoder");
var _lodash = _interopRequireDefault(require("lodash.get"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const UPPER_LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';

@@ -21,3 +23,3 @@ const SENTENCE_INIT = ' ';

const segmentSentences = str => {
const characters = str.split('');
const characters = Array.from(str);
const sentences = characters.reduce(

@@ -48,3 +50,3 @@ /*

return [...prevSentences.slice(0, -1), currentSentence + character];
}, [SENTENCE_INIT]).map(sentence => sentence.trimStart());
}, [SENTENCE_INIT]).filter(sentence => sentence !== SENTENCE_INIT).map(sentence => sentence.trimStart());
return sentences;

@@ -54,25 +56,12 @@ };

const TXTSentences = (data, feed, ctx) => {
if (!ctx.decoder) {
ctx.decoder = new _string_decoder.StringDecoder('utf8');
}
if (ctx.isLast()) {
ctx.decoder.end();
return feed.end();
return feed.close();
}
ctx.remainder = ctx.remainder ?? '';
let str;
if (Buffer.isBuffer(data)) {
str = ctx.decoder.write(data);
} else if (typeof data === 'string') {
str = data;
}
const lines = str ? segmentSentences(str) : [];
lines.unshift(ctx.remainder + lines.shift());
ctx.remainder = lines.pop();
lines.forEach(line => {
feed.write(line);
const path = ctx.getParam('path', 'value');
const value = (0, _lodash.default)(data, path);
const str = Array.isArray(value) ? value.map(item => typeof item === 'string' ? item : '').join(' ') : value;
const sentences = str ? segmentSentences(str) : [];
feed.write({ ...data,
[path]: sentences
});

@@ -87,3 +76,3 @@ return feed.end();

* ```json
* "First sentence? Second sentence. My name is Bond, J. Bond."
* { "id": 1, "value": "First sentence? Second sentence. My name is Bond, J. Bond." }
* ```

@@ -94,7 +83,8 @@ *

* ```json
* ["First sentence?", "Second sentence.", "My name is Bond, J. Bond."]
* { "id": 1, "value": ["First sentence?", "Second sentence.", "My name is Bond, J. Bond."] }
* ```
*
* @name TXTSentences
* @returns {String}
* @param {String} [path="value"] path of the field to segment
* @returns {String[]}
*/

@@ -101,0 +91,0 @@

{
"name": "@ezs/basics",
"description": "Basics statements for EZS",
"version": "1.24.0",
"version": "2.0.0",
"author": "Nicolas Thouvenin <nthouvenin@gmail.com>",

@@ -42,3 +42,3 @@ "bugs": "https://github.com/Inist-CNRS/ezs/issues",

},
"gitHead": "0f52795f9c5d1a452adbad48ab567298bb8a6bea",
"gitHead": "314a26ebcbf109ffdb6936ee4b8564e19dd17cbc",
"homepage": "https://github.com/Inist-CNRS/ezs/tree/master/packages/basics#readme",

@@ -45,0 +45,0 @@ "keywords": [

@@ -612,3 +612,3 @@ # basics

```json
"First sentence? Second sentence. My name is Bond, J. Bond."
{ "id": 1, "value": "First sentence? Second sentence. My name is Bond, J. Bond." }
```

@@ -619,7 +619,11 @@

```json
["First sentence?", "Second sentence.", "My name is Bond, J. Bond."]
{ "id": 1, "value": ["First sentence?", "Second sentence.", "My name is Bond, J. Bond."] }
```
Returns **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
#### Parameters
- `path` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** path of the field to segment (optional, default `"value"`)
Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>**
### TXTZip

@@ -626,0 +630,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