Skip to content

Latest commit

 

History

History
37 lines (24 loc) · 1009 Bytes

README.md

File metadata and controls

37 lines (24 loc) · 1009 Bytes

deep-trim Build Status npm version minzipped size

Recursively trim all the strings in a collection (object or array).

Install

$ npm install deep-trim

Usage

var deepTrim = require('deep-trim');

deepTrim('   a ')
// 'a'

deepTrim(['   a ', 1, '', 'a', '             a']);
// ['a', 1, '', 'a', 'a']

deepTrim({ a: '  a', b: 'b  ', c: '   c ', d: 'd' });
// { a: 'a', b: 'b', c: 'c', d: 'd' }

deepTrim({ a: '  a', b: 'b  ', c: ['   ca', 'cb   '], d: 'd' });
// { a: 'a', b: 'b', c: ['ca', 'cb'], d: 'd' }

Tests

$ npm test

License

Released under the MIT License.