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

stringfy

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stringfy - npm Package Compare versions

Comparing version 0.0.11 to 0.0.12

19

index.js
'use strict'
const unidecode = require('unidecode')
class Stringfy {

@@ -29,2 +31,19 @@ constructor (string) {

}
slug () {
const seperator = '-'
let string = this.string
string = unidecode(string)
string = string.replace(/[:\/\?#\[\]@!$&'()*+,;=\\%<>\|\^~£"]/g, '')
// Replace dots and spaces with a sepeator
.replace(/(\s|\.)/g, seperator)
// Convert 2 or more sepeators into just one sepeator
.replace(/-+/g, seperator)
// Make the whole thing lowercase
.toLowerCase()
if(string.substring(string.length - 1) == seperator){
string = string.substring(0, string.length - 1)
}
this.string = string
return this
}
val () {

@@ -31,0 +50,0 @@ return this.string

5

package.json
{
"name": "stringfy",
"version": "0.0.11",
"version": "0.0.12",
"description": "",

@@ -14,3 +14,6 @@ "main": "index.js",

"should": "^7.1.0"
},
"dependencies": {
"unidecode": "^0.1.7"
}
}

4

README.md

@@ -21,2 +21,6 @@ # Stringfy

stringfy('呆死ki').count()
// return slugify string, with CJK support
// like 'I love cat' => 'i-love-cat'
string('空彩观测').slug().val()
```

@@ -23,0 +27,0 @@

@@ -35,2 +35,11 @@ var stringfy = require('./index')

})
describe('slug', () => {
it('should return slugify string kong-cai-guan-ce', () => {
stringfy('空彩观测').slug().val().should.equal('kong-cai-guan-ce')
})
it('should return slugify string te-me-go-to-hell', () => {
stringfy('te me, go to hell').slug().val().should.equal('te-me-go-to-hell')
})
})
})
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