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

cjk-count

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cjk-count - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

example.js

10

index.js
var cjk = require('unicode-6.3.0/blocks/CJK Unified Ideographs/regex');
var re = new RegExp(cjk.source, 'g');
var re_char = new RegExp(cjk.source, 'g');
var re_word = new RegExp(cjk.source + '+', 'g');
module.exports = function(str) {
function count (str, word) {
word = word || false;
if (typeof str === 'string') {
return str.match(re);
return str.match(word ? re_word : re_char);

@@ -13,1 +15,3 @@ } else{

};
module.exports = count;
{
"name": "cjk-count",
"version": "1.0.1",
"version": "1.0.2",
"description": "cjk word count",
"main": "index.js",
"scripts": {
"test": "node test.js"
"test": "jasmine"
},

@@ -26,3 +26,6 @@ "repository": {

"unicode-6.3.0": "^0.1.5"
},
"devDependencies": {
"jasmine": "^2.3.1"
}
}

@@ -17,4 +17,14 @@ # cjk-count

var str = 'I am a 香港人';
console.log(cjkCount(str));
var str3 = ' No results found.人口家庭教育就業收I am a 香港人';
console.log(cjkCount(str)); // count char
console.log(cjkCount(str3, true)); // count words
```
## Test
```
npm test
```
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