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

fast-chunk-string

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-chunk-string - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

35

index.js

@@ -7,3 +7,13 @@ 'use strict';

module.exports = (str, {size, unicodeAware = false}) => {
const strLength = unicodeAware ? stringLength(str) : str.length;
str = str || '';
if (!unicodeAware) {
return getChunks(str, size);
}
return getChunksUnicode(str, size);
};
function getChunks(str, size) {
const strLength = str.length;
const numChunks = Math.ceil(strLength / size);

@@ -16,10 +26,21 @@ const chunks = new Array(numChunks);

for (; i < numChunks; ++i, o += size) {
if (unicodeAware) {
chunks[i] = runes.substr(str, o, size);
} else {
chunks[i] = str.substr(o, size);
}
chunks[i] = str.substr(o, size);
}
return chunks;
};
}
function getChunksUnicode(str, size) {
const strLength = stringLength(str);
const numChunks = Math.ceil(strLength / size);
const chunks = new Array(numChunks);
let i = 0;
let o = 0;
for (; i < numChunks; ++i, o += size) {
chunks[i] = runes.substr(str, o, size);
}
return chunks;
}

16

package.json
{
"name": "fast-chunk-string",
"version": "1.0.0",
"version": "1.0.1",
"description": "Chunk string into equal substrings with unicode support",

@@ -33,2 +33,6 @@ "license": "MIT",

],
"dependencies": {
"runes": "^0.4.3",
"string-length": "^2.0.0"
},
"devDependencies": {

@@ -40,14 +44,8 @@ "benchmark": "^2.1.4",

"fast-lorem-ipsum": "^1.1.0",
"jest": "^21.2.1",
"jest": "^22.0.4",
"prettier": "^1.9.2"
},
"jest": {
"modulePathIgnorePatterns": [
"component-test"
]
},
"dependencies": {
"runes": "^0.4.3",
"string-length": "^2.0.0"
"testEnvironment": "node"
}
}

@@ -1,2 +0,2 @@

# fast-chunk-string [![Build Status](https://travis-ci.org/vladgolubev/fast-chunk-string.svg?branch=master)](https://travis-ci.org/vladgolubev/fast-chunk-string)
# fast-chunk-string [![CircleCI](https://img.shields.io/circleci/project/github/vladgolubev/fast-chunk-string.svg)](https://circleci.com/gh/vladgolubev/fast-chunk-string)

@@ -3,0 +3,0 @@ > Chunk string into equal substrings with unicode support

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