Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@ythub/quota-matcher

Package Overview
Dependencies
Maintainers
0
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ythub/quota-matcher

Hub quota matcher utils

latest
Source
npmnpm
Version
1.2.15
Version published
Maintainers
0
Created
Source

This package is related to the Hub quotas. It contains utils which intended to evaluate which quotas are matching and which are not.

Usage example:

import { matchQuotasWithRespondent, QuotaMatchResult } from '@ythub/quota-matcher'

const ageQualificationId = '304';
const genderQualificationId = '197';

const outcome = matchQuotasWithRespondent(
  // Respondent collection
  {
    [ageQualificationId]: 22,
    [genderQualificationId]: 1857 /* male */
  },
  // Survey quotas collection
  {
    id: 1,
    name: 'Male 18-24',
    remainingCompletes: 10,
    isMandatory: true,
    isEnabled: true,
    conditions: [
      {
        range: [{ to: 24, from: 18 }],
        property: ageProperty,
      },
      {
        options: [1857],
        property: genderProperty,
      },
    ],
  }
)

switch (outcome.matchResult) {
  case QuotaMatchResult.Eligible:
    // outcome.eligibleQuotas
    // ... do something
    break
  case QuotaMatchResult.Ineligible:
  case QuotaMatchResult.Uncertain:
    // ...
}

FAQs

Package last updated on 21 Jun 2024

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