Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
object(Object, Function, Array) to string
npm i -S obj2str
# or
yarn add obj2str
./test/index.js
const { obj2str } = require('obj2str')
// test object
const obj = {
a: 1111,
b: 'fsdfs,d\'fsd',
b2: 'this\'s an object',
b3: `This's a test object`,
212: 'xxdfdf',
c: {
cc: '3333',
c2: 'sdfsf"d"fsd',
c3: {
d: 2222
}
},
k: null,
f: undefined,
g: 0,
fn: function(str) {
return str + 'hello world!'
},
fn2: (a) => a + 10,
arr: [
122,
'xxx',
{
aa: 232434,
bb: 'bb'
},
'dsfsdf'
]
}
const str = obj2str(obj, {
// initSpaces: 4,
// indentSpaces: 4,
prefix: 'const obj = ',
// doubleQuotes: true,
// keyQuote: true
})
console.log(str)
node ./test/index.js
const obj = {
212: 'xxdfdf',
a: 1111,
b: 'fsdfs,d\'fsd',
b2: 'this\'s an object',
b3: 'This\'s a test object',
c: {
cc: '3333',
c2: 'sdfsf"d"fsd',
c3: {
d: 2222
}
},
k: null,
f: undefined,
g: 0,
fn: function(str) {
return str + 'hello world!'
},
fn2: (a) => a + 10,
arr: [
122,
'xxx',
{
aa: 232434,
bb: 'bb'
},
'dsfsdf'
]
}
Method | Parameters | Description |
---|---|---|
obj2str | (o: any, options?: TypeOptions) | return string |
Props | Type | Description |
---|---|---|
initSpaces | number | Default indentation space for all lines, default: 0 |
indentSpaces | number | Number of spaces to indent when formatting, default: 2 |
prefix | string | Concatenation string prefix of the first line, default: '' |
doubleQuotes | boolean | Whether the string uses double quotes, default: false |
keyQuote | boolean | Whether the key of the object uses quote, default: false |
FAQs
object/array/function to string
The npm package obj2str receives a total of 1 weekly downloads. As such, obj2str popularity was classified as not popular.
We found that obj2str demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.