https://github.com/dawsbot/deep-blue-string
Apply prototype functions to strings deep in data types
https://github.com/dawsbot/deep-blue-string
Last synced: over 1 year ago
JSON representation
Apply prototype functions to strings deep in data types
- Host: GitHub
- URL: https://github.com/dawsbot/deep-blue-string
- Owner: dawsbot
- License: mit
- Created: 2016-02-08T22:52:22.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-02-14T23:38:17.000Z (over 10 years ago)
- Last Synced: 2025-02-16T02:32:50.029Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 110 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# deep-blue-string [](https://travis-ci.org/dawsonbotsford/deep-blue-string) [](https://badge.fury.io/js/deep-blue-string)
> Apply prototype funtions to strings deep in data types

## Install
```
npm install --save deep-blue-string
```
## Usage
```js
const dbs = require('deep-blue-string');
//Sanitize any data type
dbs({userInput: 'DROP TABLE admin'}, String.prototype.replace, ['DROP TABLE', 'not in my house']);
//=> {userInput: 'not in my house admin'}
```
## API
### dbs(target, function, [fnArgs])
##### target
*Required*
Type: Any
##### function
*Required*
Type: `function`
##### fnArgs
*Optional*
Type: `string` || `array`
Description: If the user inputted function takes arguments, supply them here. For multiple arguments (like `String.prototype.replace`, input them as an array).
#### Function overview
Apply function to all strings in `target`. Deeply nested strings will be found and operated on. No casting will be done on inputted `target`.
## Features
Supported `target` Data Types:
* String
* Array
* Objects
* Object object
* Strings as objects
* Arrays as objects
* Numbers as objects (returned unmodified)
* Booleans as objects (returned unmodified)
* Regex as objects (returned unmodified)
* Function as objects (returned unmodified)
* Date objects (returned unmodified)
* Number (returned unmodified)
* Boolean (returned unmodified)
* Undefined (returned unmodified)
* Function (returned unmodified)
* Symbol (returned unmodified)
## Related
* [object-types](https://github.com/dawsonbotsford/object-types)
* [hugg](https://github.com/dawsonbotsford/hugg)
## License
MIT © [dawsonbotsford](http://dawsonbotsford.com)