How to use the @iabtcf/core.TCModel.consentLanguages function in @iabtcf/core

To help you get started, we’ve selected a few @iabtcf/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github InteractiveAdvertisingBureau / iabtcf-es / modules / testing / src / TCModelFactory.ts View on Github external
const latestGVL = GVLFactory.getLatest();

    const numPurposes = Object.keys(latestGVL.purposes).length;
    const numVendors = Object.keys(latestGVL.vendors).length;
    const numSpecialFeatures = Object.keys(latestGVL.specialFeatures).length;

    const tcModel = new TCModel();

    tcModel.cmpId = makeRandomInt(2,100);
    tcModel.cmpVersion = makeRandomInt(1,10);
    tcModel.consentScreen = makeRandomInt(1,5);
    tcModel.isServiceSpecific = !!makeRandomInt(0,1);
    tcModel.vendorListVersion = makeRandomInt(1, latestGVL.vendorListVersion);

    let counter = 0;
    const rand = makeRandomInt(1, TCModel.consentLanguages.size);
    TCModel.consentLanguages.forEach((lang: string): void => {

      counter ++;
      if(counter === rand) {

        tcModel.consentLanguage = lang;
      }

    });

    tcModel.publisherCountryCode = String.fromCharCode(makeRandomInt(65, 90)) + String.fromCharCode(makeRandomInt(65, 90));

    const now = (new Date()).getTime();
    const GDPRMageddon = 1576883249;
    tcModel.created = new Date(makeRandomInt(GDPRMageddon, now)); 
    tcModel.lastUpdated = new Date(makeRandomInt(tcModel.created.getTime(), now));
github InteractiveAdvertisingBureau / iabtcf-es / modules / testing / src / TCModelFactory.ts View on Github external
const numPurposes = Object.keys(latestGVL.purposes).length;
    const numVendors = Object.keys(latestGVL.vendors).length;
    const numSpecialFeatures = Object.keys(latestGVL.specialFeatures).length;

    const tcModel = new TCModel();

    tcModel.cmpId = makeRandomInt(2,100);
    tcModel.cmpVersion = makeRandomInt(1,10);
    tcModel.consentScreen = makeRandomInt(1,5);
    tcModel.isServiceSpecific = !!makeRandomInt(0,1);
    tcModel.vendorListVersion = makeRandomInt(1, latestGVL.vendorListVersion);

    let counter = 0;
    const rand = makeRandomInt(1, TCModel.consentLanguages.size);
    TCModel.consentLanguages.forEach((lang: string): void => {

      counter ++;
      if(counter === rand) {

        tcModel.consentLanguage = lang;
      }

    });

    tcModel.publisherCountryCode = String.fromCharCode(makeRandomInt(65, 90)) + String.fromCharCode(makeRandomInt(65, 90));

    const now = (new Date()).getTime();
    const GDPRMageddon = 1576883249;
    tcModel.created = new Date(makeRandomInt(GDPRMageddon, now)); 
    tcModel.lastUpdated = new Date(makeRandomInt(tcModel.created.getTime(), now));

@iabtcf/core

Ensures consistent encoding and decoding of TC Signals for the iab. Transparency and Consent Framework (TCF).

Apache-2.0
Latest version published 1 year ago

Package Health Score

73 / 100
Full package analysis