New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

mocko

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mocko

super simple schema based mock data generator. works integrated with fakerjs.

latest
Source
npmnpm
Version
0.0.3
Version published
Maintainers
1
Created
Source

mocko

super simple schema based mock data generator. works integrated with fakerjs.

Installation

npm i mocko

Usage

the scheme runs entirely on fakerjs functions. You can check the faker api for more. https://fakerjs.dev/api/

import mocko from 'mocko';

mocko({
  id: 'database.mongodbObjectId',
  name: 'name.fullName',
  photo: 'internet.avatar',
})
{
  "id": "b0d11bd9f60fedcf6beee3fe",
  "name": "Bethany Lebsack III",
  "photo": "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/688.jpg"
}

use of parameters

import mocko from 'mocko';

mocko({
  phone: ['phone.number', '501-###-###'],
  texts: ['lorem.paragraphs', 5, '<br/>\n'],
})
{
  "phone": "501-111-741",
  "texts": "Ratione animi corrupti deleniti molestias commodi architecto eligendi. Quaerat perspiciatis aliquam velit nostrum aspernatur. Veritatis provident facere nulla tenetur. Voluptates commodi illum laborum.
\nQuas voluptas commodi commodi quas deleniti quo minima. Voluptatibus quo nulla fugit quam sit. Eaque doloribus iusto minus animi distinctio beatae magni similique. Reiciendis quo a totam veritatis."
}

creating arrays

import mocko from 'mocko';

mocko({
  'genres#5': 'music.genre',
  'colors#3': ['internet.color', 50, 50, 50],
})
{
  "genres": [
    "Latin",
    "Metal",
    "Electronic",
    "Stage And Screen",
    "Non Music"
  ],
  "colors": [
    "#4e3c29",
    "#5b8321",
    "#744739"
  ]
}

mocko works in English by default. You can use changeLocale util to change locale.

https://fakerjs.dev/guide/localization.html#available-locales

import mocko, { changeLocale } from 'mocko';

await changeLocale('tr')

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Keywords

mock

FAQs

Package last updated on 31 Mar 2023

Did you know?

Socket

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.

Install

Related posts