
Product
Introducing Socket Firewall Enterprise: Flexible, Configurable Protection for Modern Package Ecosystems
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.
@berish/pathof
Advanced tools
Контроль доступа к полям определенного объекта по динамическому ключу. Полная поддержка typescript
npm install @berish/pathof --save
Пример
import { of } from '@berish/pathof';
const model = {
login: 'root',
password: 'admin123456',
profile: {
firstname: 'Ravil',
lastname: 'Berishev',
},
};
const pathResult = of(model);
const login = pathResult('login');
console.log(login.get()); // 'root'
console.log(login.original); // === model
console.log(login.path); // ['login'];
login.set('root2');
console.log(login.get()); // root2
console.log(model.login); // root2
Конфигурирование (с поддержкой async/await)
import { of } from '@berish/pathof';
const model = {
login: 'root',
password: 'admin123456',
profile: {
firstname: 'Ravil',
lastname: 'Berishev',
age: 18
},
};
const pr = of(model)('profile')('age').config<string>({
afterGet: ({ value }) => `${value}`,
beforeSet: ({ value }) => ,
});
const age = pr.get();
console.log(age, typeof age); // 18 string
pr.set('20');
console.log(model.profile.age, typeof model.profile.age); // 20 number
const pr2 = of(model)('profile')('age').config<string>({
afterGet: ({ value }) => `${value}`,
beforeSet: async ({ value }) => {
await new Promise(resolve => setTimeout(resolve, 1000));
Number.parseInt(value, 10)
},
});
const age = pr2.get();
console.log(age, typeof age); // 20 string
await pr2.set('30');
console.log(model.profile.age, typeof model.profile.age); // 30 number
FAQs
Control access to the fields of a specific object using a dynamic key
We found that @berish/pathof 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.

Product
Socket Firewall Enterprise is now available with flexible deployment, configurable policies, and expanded language support.

Security News
Open source dashboard CNAPulse tracks CVE Numbering Authorities’ publishing activity, highlighting trends and transparency across the CVE ecosystem.

Product
Detect malware, unsafe data flows, and license issues in GitHub Actions with Socket’s new workflow scanning support.