Gathering detailed insights and metrics for pickpocket.js
Gathering detailed insights and metrics for pickpocket.js
Gathering detailed insights and metrics for pickpocket.js
Gathering detailed insights and metrics for pickpocket.js
Small, simple, and to the point collection around common data structures (Form Field with list of Error messages, Hook Events with list of callbacks, etc...)
npm install pickpocket.js
Typescript
Module System
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
1 Stars
4 Commits
1 Forks
1 Watchers
1 Branches
1 Contributors
Updated on May 07, 2020
Latest Version
1.0.0
Package Id
pickpocket.js@1.0.0
Unpacked Size
374.34 kB
Size
72.67 kB
File Count
32
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Simplification at its finest
1npm install --save-dev pickpocket.js
1yarn add pickpocket.js --save
Simplified Wrapper Around Common Data Structure
Determine if there are "any" items in pocket
1const pocket = pickpocket({ 2 name: ['name is a required', 'name must be a string'], 3 email: ['email is a required field', 'email must be an email'] 4}); 5 6 7pocket.any();
true
Retrieve all data within pocket
1const pocket = pickpocket({ 2 name: ['name is a required', 'name must be a string'], 3 email: ['email is a required field', 'email must be an email'] 4}); 5 6 7pocket.all();
{
name: ['name is a required', 'name must be a string'],
email: ['email is a required field', 'email must be an email']
}
1let data = { name: '', email: '' }; 2let rules = { name: 'required', email: 'email|required' }; 3let validation = validator(data, rules).validate(); 4 5validation.errors().all();
Flat list of all pocket field items
1const pocket = pickpocket({ 2 name: ['name is a required', 'name must be a string'], 3 email: ['email is a required field', 'email must be an email'] 4}); 5 6 7pocket.list();
[
'name is a required',
'name must be a string',
'email must be an email',
'email is a required field',
]
Set entirety of pocket data
1const pocket = pickpocket({ 2 name: ['name is a required', 'name must be a string'], 3 email: ['email is a required field', 'email must be an email'] 4}); 5 6pocket.set({ 7 name: ['eyy'], 8 something: ['ohh'] 9});
Forget all pocket data
1const pocket = pickpocket({ 2 name: ['name is a required', 'name must be a string'], 3 email: ['email is a required field', 'email must be an email'] 4}); 5 6pocket.forget(); 7pocket.all(); // {}
Determine if specified field "has" items
1const pocket = pickpocket({ 2 tag: [], 3 name: [], 4 email: ['email is a required', 'email must be an email'], 5}); 6 7 8pocket.has('tag'); // false 9pocket.has('name'); // false 10pocket.has('email'); // true 11pocket.has('something_else'); // false
Get _first_ item from specific field
1const pocket = pickpocket({ 2 tag: [], 3 name: [], 4 email: ['email is a required', 'email must be an email'], 5}); 6pocket.get('email');
List items for specific field
1const pocket = pickpocket({ 2 tag: [], 3 name: [], 4 email: ['email is a required', 'email must be an email'], 5}); 6pocket.list('email');
['email is a required', 'email must be an email']
Add item to specific field
1const pocket = pickpocket({ 2 tag: [], 3 name: [], 4 email: ['email is a required', 'email must be an email'], 5}); 6 7pocket.add('tag', 'simplified'); 8pocket.list('tag'); // ['simplified']; 9 10pocket.add('email', 'extrafied'); 11pocket.list('email'); // ['email is a required', 'email must be an email', 'extrafied']
Set specified field items
1const pocket = pickpocket({ 2 tag: [], 3 name: [], 4 email: ['email is a required', 'email must be an email'], 5}); 6 7pocket.set('email', ['set', 'email', 'items', 'list']); 8 9pocket.list('email');
['set', 'email', 'items', 'list']
Forget items on the specified field
1const pocket = pickpocket({ 2 tag: [], 3 name: [], 4 email: ['email is a required', 'email must be an email'], 5}); 6 7pocket.forget('email'); 8 9pocket.list('email');
[]
Common Example
1 2const pickpocket = require('pickpocket.js'); 3 4const errors = pickpocket({ 5 name: ['name is required', 'name is not a string', 'name needs to be cool'], 6 email: ['email field must be an email'] 7}); 8 9// errors.all() 10// errors.list() 11// errors.any() 12// errors.add('name', 'message') 13// errors.list('email') 14// errors.has(field) 15// errors.set({}) 16// errors.set('email', []) 17// errors.forget() 18// errors.forget('email') 19// etc...
Advanced example
1 2const pickpocket = require('pickpocket.js'); 3 4const life = pickpocket({ 5 before: [ 6 firstBeforeMomentCallback, 7 secondBeforeMomentCallback, 8 thirdBeforeMomentCallback 9 ], 10 passed: [ 11 firstPassedMomentCallback, 12 secondPassedMomentCallback 13 ], 14 failed: [ 15 firstFailedMomentCallback 16 ], 17 after: [ 18 firstAfterMomentCallback, 19 secondAfterMomentCallback 20 ], 21}); 22 23life.eventful = (human = {}, moment) => { 24 if (life.has(moment)) { 25 this.list(moment).forEach(event => event(human)); 26 27 life.forget(moment); 28 } 29 30}; 31 32const moments = ['before', 'during', 'failed', 'passed', 'after']; 33 34/** 35 * Add during life moment 36 */ 37life.set('during', [ 38 person => console.log(`${person.name} is going to kindergarden`), 39 person => console.log(`${person.name} was held back in kindergarden`), 40 person => { 41 person.age++; 42 43 console.log(`${person.name} had there birthday today`) 44 }, 45 person => console.log(`${person.name} is ${person.age} and still in kindergarden`), 46 person => console.log(`${person.name} is going to have one heck of a time during life`), 47 // etc... 48]); 49 50 51let human = { age: 0, name: 'zak', birthed: 'April 22 1997' }; 52moments.forEach(moment => life.eventful(human, moment)) 53 54 55### Contribute 56 57PRs are welcomed to this project. 58If you want to improve the pickpocket.js library, add 59functionality or improve the docs please feel free to submit a PR. 60 61 62### License 63 64MIT © [Zachary Horton ~ (Clean Code Studio)](https://github.com/zhorton34/pickpocket.js)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 0/4 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
license file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More