Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aligay/safe-trim
π³ trim all unsafe space
https://github.com/aligay/safe-trim
trim trimming zero-width-space
Last synced: 6 days 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 (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-09-26T03:53:00.000Z (3 months ago)
- Last Synced: 2024-12-09T19:13:34.163Z (13 days ago)
- Topics: trim, trimming, zero-width-space
- Language: JavaScript
- Homepage: https://npmjs.org/safe-trim
- Size: 2.51 MB
- Stars: 68
- Watchers: 3
- Forks: 4
- Open Issues: 23
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# safe-trim
---[![Build Status](https://travis-ci.org/aligay/safe-trim.svg?branch=master)](https://travis-ci.org/aligay/safe-trim/branches)
[![codecov](https://codecov.io/gh/aligay/safe-trim/branch/master/graph/badge.svg)](https://codecov.io/gh/aligay/safe-trim)
[![dependencies Status](https://david-dm.org/aligay/safe-trim/status.svg)](https://david-dm.org/aligay/safe-trim)
[![devDependencies Status](https://david-dm.org/aligay/safe-trim/dev-status.svg)](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)