
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
dashingmodels
Advanced tools
Generate pre-configured objects from presets like it's nothing. (Model Factories just like in Laravel)
Generate pre-configured objects from presets like it's nothing. (Model Factories just like in Laravel)
# Using npm
$ npm install dashing --save-dev
# Using yarn
$ yarn add dashing --save-dev
// Import with typescript / ES6
import makeDashing from "dashing"
// Import with node
const makeDashing = require("dashing")
Dashing does not comes as a singleton to give you flexibility. This means you can have multiple instances if needed, but you have to instantiate it by yourself.
Fortunately, this is quite simple:
// someFile.js
import makeDashing from "dashing"
export const dashing = makeDashing({}) // will return a unique instance of dashing
// someOtherFile.js
import dashing from "./someFile" // if exported as default
import { dashing } from "./someFile" // if not exported as default
let freshPreConfiguredUserObject = dashing(User)
.make() // have fun
// someFile.js
import makeDashing from "dashing"
let dashing = makeDashing({}) // will return a unique instance of dashing
// Creating the default state for every User generated by dashing
dashing.define( User, ["Bruce", "Wayne", "🥞"] ) // new User(Bruce, Wayne, 🥞)
// Creating the default state for every Product generated by dashing with dynamic data 🦄 (see at the end for generators)
dashing.define( Product, generator => [generator.someMethod(), "Philosopher stone"] ) // equals new Product(9.99, "philospher stone")
export default dashing
// or if multiple exports
export { dashing, otherStuff }
But wait, dashing is way more powerful than that. You can haz presets 😍
// someFile.js
import makeDashing from "dashing"
let dashing = makeDashing({})
dashing.define( User, ["Bruce Wayne", "🥞"] ) // new User(Bruce, Wayne, 🥞)
.registerPreset( "superHero", generator => [ "Catwoman", "🥛" ] ) // new User(Catwoman, "🥛" )
.registerPreset( "superVilain", generator => [ "twoface", "🍉" ] ) // new User( "twoface", "🍉" )
.registerPreset( "batman", generator => [ undefined, "🍕" ] ) // new User( "Bruce Wayne", "🍕" )
dashing.define( Product, generator => [generator.someMethod(), 10, "Philosopher stone"] ) // equals new Product(9.99, 10, "philospher stone")
.registerPreset( "soldOut", generator => [ undefined, 0] ) // equals new Product(9.99, 0, "philospher stone")
.registerPreset( "crappy", generator => [1, 100, "Crappy product"] ) // equals new Product(1, 100, "Crappy product)
export default dashing
You might not use you constructor to configure your objects. Or use a bit of constructors and methods. Fine with me, here's how you can do that with dashing 😎
// someFile.js
import makeDashing from "dashing"
let dashing = makeDashing({})
const myDefaultCallback = (instance, _) => {
instance.setBreakfast("🥞")
}
const myCallbackForAState = (instance, _) => {
return instance.setMood("tired") // If you return the object (in case immutable or something, we will use it for the next process)
}
dashing.define( User, ["Alfred"], myDefaultCallback) // Will apply this cllback to every created instance
.registerPreset( "tiredAlfred", () => [], myCallbackForAState) // Will apply this callback to instance generated with this state
export default dashing
Now that you have instanciated dahsing and defined your presets, let's make some 😎
import dashing from "./someFile"
const instance = dashing(User)
.make(); // By the way, if you registered a callback it will have been applied to the resulting instance 😁
import dashing from "./someFile"
const instance = dashing(User)
.make([undefined, "else"]); // Considering defaults ["Catwoman", "something"], will make new User("catwoman", "else")
import dashing from "./someFile"
const instance = dashing(User)
.preset( "tiredAlfred" ) // Each state params & it's callback will be applied on top of the other in the oreder you asked for
.preset( "hungryAlfred" ) // (aka here moodyAlfred on top of hungryAlfred which is applied on top of tiredAlfred
.preset( "moodyAlfred" )
.make();
// or
const instance = dashing(User)
.preset( ["tiredAlfred", "hungryAlfred", "moodyAlfred"] )
.make();
import dashing from "./someFile"
const instanceS = dashing(User)
.preset( "tiredAlfred" )
.times(99)
.make(); // we return an array when you ask for multiple instances 📦
So, I intended to ship it with a default data generator. But frankly the package was 10x th size soooo... 😱
Here are your options:
// someFile.js
import makeDashing from "dashing"
import faker from "faker" // import your generator
let dashing = makeDashing(faker) // pass it to makeDashing and, voila! 🤑
dashing.define(User, generator => {
return [generator.someMethodOfUsedGenerator(), {active: true, id: generator.makeMeSomeId()}]
}, (instance, generator) => { // Available for callback too ❤️
instance.setSomething(generator.generateSomething())
})
export default dashing
// someRandomFile.js
import dashing from "./someFile"
dashing(User)
.make(generator => [generator.generateSomeStuff()]) // For overrides too 😍
I just pass you the generator, so you can pass whatever object you want as generator.
// someFile.js
import makeDashing from "dashing"
// This is a pointless but valid generator
const quotesGenerator = {
giveMeADrakeQuote: () => "I like sweaters. I have a sweater obsession, I guess. -Drake"
}
let dashing = makeDashing(quotesGenerator) // pass it to makeDashing and, voila! 🤑
dashing.define(User, generator => [{greeting: generator.giveMeADrakeQuote()}])
export default dashing
FAQs
Generate pre-configured objects from presets like it's nothing. (Model Factories just like in Laravel)
The npm package dashingmodels receives a total of 3 weekly downloads. As such, dashingmodels popularity was classified as not popular.
We found that dashingmodels 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
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.