Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
@cookbook/dot-notation
Advanced tools
Object readings and complex transformations using dot notation syntax.
Object readings and complex transformations made easy by using
dot.notation.syntax[]
Play around with dot-notation and experience the magic!
npm install @cookbook/dot-notation --save
#or
yarn add @cookbook/dot-notation
import { pick } from '@cookbook/dot-notation';
const source = {
person: {
name: {
firstName: 'John',
lastName: 'Doe'
},
address: [
{
street: 'Infinite Loop',
city: 'Cupertino',
state: 'CA',
postalCode: 95014,
country: 'United States'
},
]
}
};
pick(source, 'person.name');
//output { firstName: 'John', lastName: 'Doe' }
pick(source, 'person.address[0].street');
//output "Infinite Loop"
import { parse } from '@cookbook/dot-notation';
const source = {
'person.name.firstName': 'John',
'person.name.lastName': 'Doe',
'person.address[].street': 'Infinite Loop',
'person.address[].city': 'Cupertino',
'person.address[].postalCode': 95014,
};
parse(source);
/* output
{
person: {
name: {
firstName: 'John',
lastName: 'Doe',
},
address: [
{
street: 'Infinite Loop',
city: 'Cupertino',
postalCode: 95014,
},
],
},
}
*/
where
[n]
represents the array index position to insert the element
import { parse } from '@cookbook/dot-notation';
const source = {
'[0].street': 'Infinite Loop',
'[0].city': 'Cupertino',
'[0].postalCode': 95014,
'[1].street': '1600 Amphitheatre',
'[1].city': 'Mountain View',
'[1].postalCode': 94043,
'[2][0]': 'hobbies',
'[2][1][0]': ['coding'],
'[2][1][1]': ['gaming'],
};
parse(source);
/* output
[
{
"postalCode": 95014,
"city": "Cupertino",
"street": "Infinite Loop"
},
{
"postalCode": 94043,
"city": "Mountain View",
"street": "1600 Amphitheatre"
},
[
"hobbies",
[["coding"],["gaming"]]
]
]
*/
import { parseKey } from '@cookbook/dot-notation';
const path = 'person.name';
const value = 'John Doe';
parseKey(path, value);
/* output
{
person: {
name: 'John Doe',
},
}
*/
FAQs
Object readings and complex transformations using dot notation syntax.
The npm package @cookbook/dot-notation receives a total of 126 weekly downloads. As such, @cookbook/dot-notation popularity was classified as not popular.
We found that @cookbook/dot-notation 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
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.