npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

qix-faker

v0.3.0

Published

Generate fake Qlik Engine data in the shape of hypercubes and listobjects.

Downloads

272

Readme

qix-faker

Powered by faker.js

Generate fake Qlik Engine data in the shape of hypercubes and listobjects.

Great for prototyping with picasso.js, nebula.js and any other time when a real Qlik Engine is not available.

Usage

node.js

npm install qix-faker
const { hypercube, listobject } = require('qix-faker');

const hc = hypercube({
  dimensions: [f => f.commerce.product()],
  measures: [f => f.commerce.price(100, 5000, 2, '$')],
  numRows: 3,
});

const lo = listobject({
  dimension: [f => f.commerce.product()],
  numRows: 5,
});

API

qixFaker.hypercube(options)

  • options <object>
    • dimensions <Array<field>> - Dimensions.
    • measures <Array<field>> - Measures.
    • numRows <number> - Number of rows to generate.
    • seed <number> - Set the same number to generate consistent results.
qixFaker.hypercube({
  numRows: 10,
  seed: 5,
  dimensions: [
    {
      value: (faker, rowIdx) => faker.date.month(),
    },
  ],
});

qixFaker.listobject(options)

  • options <object>
    • dimension <field>.
    • numRows <number> - Number of rows to generate.
    • seed <number> - Set the same number to generate consistent results.
qixFaker.listobject({
  numRows: 10,
  seed: 5678,
  dimension: f => d.name.firstName(),
});

types

field <function | object>

A field configuration can take on two different shapes:

<function(faker, rowIndex)>

A function which is provided the faker instance as first parameter, and the rowIndex as the second. See the faker api for details on params of each method.

hypercube({
  dimensions: [(faker, idx) => faker.commerce.product()],
  measures: [(faker, idx) => faker.finance.amount(100, 3000, 2, '$')],
});
<object>

Using an object provides more control:

  • value: <function(faker, rowIndex)> - Same function as above.
  • maxCardinalRatio <number> - A value between 0 - 1 to limit the uniqueness of dimension values.
  • attrDims <Array<field>> - Attribute dimensions.
  • attrExps <Array<field> - Attribute expression.
  • override <object> - Set custom properties on the field.
hypercube({
  numRows: 100,
  dimensions: [
    {
      value: f => f.address.city(),
      maxCardinalRatio: 0.4,
      attrDim: [f => f.commerce.color()],
      attrExps: [f => f.random.number()]
      override: {
        qFallbackTitle: 'City',
        qLocked: true,
      },
    },
  ],
});

In the above example, 100 rows of data is generated using the city dataset provided in faker, there is however no guarantee that all 100 rows will be unique.

In some cases though, it might be desirable to limit the uniqueness of the generated values; maxCardinalRatio provides a way to do just that.

Assume we want to generate some data containing cities grouped by country, by setting maxCardinalRatio to a low number we can create such a dataset.

hypercube({
  numRows: 80,
  dimensions: [
    {
      value: f => f.address.country(),
      maxCardinalRatio: 0.1,
    },
    {
      value: f => f.address.city(),
    },
  ],
});

In the above example, the first 8 rows (numRows * ratio) of country will be the same, while city will be randomized, thus creating groups.