pico-common
v0.15.2
Published
pico common tools
Downloads
77
Maintainers
Readme
pico-common
A pico sized (~ 7kb) with zero dependency javascript library for commonly overlooked utility functions for both nodejs and the browser.
this library goes well with commonly used libraries such as lodash and react with little or no overlapping.
features
Below are the main features
data validator
A data driven data validator, suitable for simple to very complicated data structure. all you need is
- define a schema/specification of your data
- pass the schema and your data to the validator
- it returns the result
deep merging
Like Object.assign but it does deep merging for object and array
route parser & route builder
building something like express router? this function can help you
/pico/common/str/route
+/pico/:lib/:mod/:fun
-> {lib: 'common', mod: 'str', fun: 'route}
/pico/:lib/:mod/:fun
+ {lib: 'common', mod: 'str', fun: 'route} ->/pico/common/str/route
cronjob
Need a cron schedule expressions parser? this is a pure javascript implementation can run on the browsers and nodejs. designed to work with setTimeout
a javascript test framework for javascript lovers
expect('style').is.very.hard.to.remember.and.use('?'). Javascript operators is all you need.
this framework supported serial and pararellel test cases execution.
module
A list of functions to you help to build your own sandbox module/dependency with asynchronous loader (similar to AMD)
call stack
printing javascript function call stack? this is for you
cleaner JSON.parse and JSON.stringify
these parse and stringify functions are designed to avoid unnecessary json stringify and parse and stringify-again in your workflow
for example
- A frontend stringified a big data structure for a request body
- expressjs bodyparser parsed entire request body but only part of them are use in server-side logic
- backend's model stringified part of the request body again and save it to db
with these functions
- frontend specially stringify the server needed data and db needed data in one string
- backend only parse backend needed data for server-side logic
- database needed can be saved as it is to db without stringification
json path
xpath for json
optional chaining
A data driven optional chaining, a optional chaining that can be saved and transport over network
html template engine
A 23 LOC html template engine
installing
click here browser and nodejs installation instruction