
Research
PyPI Package Disguised as Instagram Growth Tool Harvests User Credentials
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.
get-else-set
Advanced tools
getElseSet is a utility function to check if a property (of any nested level) exists. If the property does not exist, the value is set to 'null' or a value of your choice.
getElseSet is a utility function to check if a property (of any nested level) exists. If the property does not exist, the value is set to 'null' or a value of your choice.
This is useful when mapping over and restructuring JSON objects that have near similar properties, but some may be undefined.
For example, you may have a NoSQL collection where a few documents in the collection are missing a property. Using getElseSet you can restructure your documents, and when met by an undefined property you can set it to 'null' or a value of your choice.
I developed this to assist with migrating from a NoSQL DB to SQL DB in which the NoSQL documents were not all the same.
Use it synchronously or asynchronously!
`
// Synchronous
getElseSet.sync(checkPropertyArray, object, setValue[Optional, default is null])
// Asynchronous
getElseSet.async(checkPropertyArray, object, setValue[Required], callback)
`
Example Data Here Example Script Here or below.
`
'use strict'
const getElseSet = require('../getElseSet');
const fs = require('fs');
// The properties you want to check for. In our example, we use nested properties.
const myCheckArray = [
'data.type',
'data.attributes.title',
'data.attributes.body'
]
// Get data function. You can use anything to pull in your JSON data.
fs.readFile('./example.data.json', 'utf8', (err, data) => {
let jsonRes = JSON.parse(data);
jsonRes.map(o => {
// #### Synchronous Example!
getElseSet.sync(myCheckArray, o, 'Sync Function: Replaced value!')
/*
Output:
[
{
data_type: 'articles',
data_attributes_title: 'JSON API paints my bikeshed!',
data_attributes_body: 'The shortest article. Ever.'
},
{
data_type: 'articles',
data_attributes_title: 'JSON API paints my bikeshed!',
Replaced Value -> data_attributes_body: 'Sync Function: Replaced value!'
}
]
*/
// #### Asynchronous Example!
getElseSet.async(myCheckArray, o, 'Async Function: Replaced value!', result => {
/*
Output:
[
{
data_type: 'articles',
data_attributes_title: 'JSON API paints my bikeshed!',
data_attributes_body: 'The shortest article. Ever.'
},
{
data_type: 'articles',
data_attributes_title: 'JSON API paints my bikeshed!',
Replaced Value -> data_attributes_body: 'Async Function: Replaced value!'
}
]
*/
})
})
})
`
FAQs
getElseSet is a utility function to check if a property (of any nested level) exists. If the property does not exist, the value is set to 'null' or a value of your choice.
The npm package get-else-set receives a total of 0 weekly downloads. As such, get-else-set popularity was classified as not popular.
We found that get-else-set 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.
Research
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.
Product
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
Security News
Research
Socket uncovered two npm packages that register hidden HTTP endpoints to delete all files on command.