Comparing version 0.0.1 to 0.0.11
@@ -26,2 +26,5 @@ 'use strict' | ||
} | ||
count () { | ||
return this.string.match(/[\u00ff-\uffff]|\S+/g).length | ||
} | ||
val () { | ||
@@ -28,0 +31,0 @@ return this.string |
{ | ||
"name": "stringfy", | ||
"version": "0.0.1", | ||
"version": "0.0.11", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -18,2 +18,5 @@ # Stringfy | ||
stringfy(' hello ').trim().val() | ||
// return words count => 3, with CJK support | ||
stringfy('呆死ki').count() | ||
``` | ||
@@ -20,0 +23,0 @@ |
20
test.js
@@ -8,11 +8,29 @@ var stringfy = require('./index') | ||
it('should return camelCased string getElementById', () => { | ||
it('should return camelCased string getElementById from -', () => { | ||
stringfy('get-element-by-id').camelCase().val().should.equal('getElementById') | ||
}) | ||
it('should return camelCased string getElementById from _', () => { | ||
stringfy('get_element_by_id').camelCase().val().should.equal('getElementById') | ||
}) | ||
it('should return camelCased string getElementById from both _ and -', () => { | ||
stringfy('get_element_by-id').camelCase().val().should.equal('getElementById') | ||
}) | ||
}) | ||
describe('reverse', () => { | ||
it('should return reversed string edcba', () => { | ||
stringfy('abcde').reverse().val().should.equal('edcba') | ||
}) | ||
}) | ||
describe('count', () => { | ||
it('should return the words count 2 of string hello', () => { | ||
stringfy('hello world').count().should.equal(2) | ||
}) | ||
it('should return the words count 3 of CJK string', () => { | ||
stringfy('呆死ki').count().should.equal(3) | ||
}) | ||
}) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3174
64
26