https://github.com/aligay/safe-trim
π³ trim all unsafe space
https://github.com/aligay/safe-trim
trim trimming zero-width-space
Last synced: about 2 months ago
JSON representation
π³ trim all unsafe space
- Host: GitHub
- URL: https://github.com/aligay/safe-trim
- Owner: aligay
- License: mit
- Created: 2016-08-11T07:46:52.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2024-09-26T03:53:00.000Z (8 months ago)
- Last Synced: 2025-03-29T07:02:59.225Z (2 months ago)
- Topics: trim, trimming, zero-width-space
- Language: JavaScript
- Homepage: https://npmjs.org/safe-trim
- Size: 2.51 MB
- Stars: 69
- Watchers: 2
- Forks: 4
- Open Issues: 23
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# safe-trim
---[](https://travis-ci.org/aligay/safe-trim/branches)
[](https://codecov.io/gh/aligay/safe-trim)
[](https://david-dm.org/aligay/safe-trim)
[](https://david-dm.org/aligay/safe-trim?type=dev)## install
```
npm install safe-trim
```
## use
```
import safeTrim from 'safe-trim'
safeTrim(' aβββββ―βb ')
```## remove Invisible spaces
```
let str = ' "a":1 a \r\n\r\tΒ αα ββββββ ββββββ―βγb '
let ret = safeTrim(str)
expect(ret).toEqual('"a":1 a\n\nb')
```## convert CR CR-LR into LR
```
a\r\n\r\nb => 'a\n\nb'
a\r\rb => 'a\n\nb'
a\r\r\nb => 'a\n\nb'
```## remove BOM
```
JSON.parse('ο»Ώ{"a":1}') // βοΈError because BOMJSON.parse(safeTrim('ο»Ώ{"a":1}')) // β
```## more feature
[more feature](spec/test_spec.js)