calculate-conditions
Calculate conditions
Last updated 10 months ago by jhuegar .
ISC · Original npm · Tarball · package.json
$ cnpm install calculate-conditions 
SYNC missed versions from official npm registry.

calculate-conditions

Return configuration nodes with 'isActive' node where value is true or false in function conditions properties

Install

npm install calculate-conditions

Example

const calculateConditions = require('calculate-conditions');

// User example
   const user = {
        // UserAgent properties
        // Example appUserAgent:
        // F8C3150BDFF86F3B1A092761;Android;samsung;SM-G920F;1440x2560;Android;6.0.1;Android;6.0.1;appName;7.5;xxxhdpi

            uid : "F8C3150BDFF86F3B1A092761",
            platform : "Android",
            brand : "samsung",
            model : "SM-G920F,
            resolution : "1440x2560",
            os : "Android",
            osVersion : "6.0.1",
            app : "appName",
            appVersion : "7.5",
            screenDensity : "xxxhdpi",
            webviewVersion : "Chrome/58.0.3029.83"

        // Session and apps properties
            id = 000000001R;
            isEmployee = true;

        // Env properties
        // Example referer:
        // https://www.aaaaaa.com/qa/feature-DB-727-example/apps/appName1/index.html

            referer = {
                domain : "www.aaaaaa.com",
                env : "qa",
                branch : "feature-DB-727-example",
                path : "apps",
                app : "appName1"
            };
            lang = "spa";
    };

// Conditions example
    const "conditions": [
              {"isEnvironment": "lh,ei,au,qa,qt", "minAppVersion": "6.6.0"}
           ]

    const "conditions": [
              {"isEnvironment": "ei", "value": "initialMessageTitleEI"},
              {"isEnvironment": "qa", "value": "initialMessageTitleQA"},
              {"isEnvironment": "pr", "value": "initialMessageTitlePR"}
           ]

    const "conditions": [
              {"isPlatform":"Android", "minOsVersion":"5.0", "minAppVersion": "4.9.0"},
              {"isPlatform":"iPhone", "minOsVersion":"9.0", "minAppVersion": "4.9.0"}
           ]

//every condition node:
const evalCond = calculateConditions.calculateConditions(user, conditions);


//RESULT: {"isActive": true/false}

Conditions:

Conditions functions are configurable in conditions.js

Actual conditions:

  • minAppVersion
  • maxAppVersion
  • minOsVersion
  • maxOsVersion
  • isPlatform
  • isNotPlatform
  • isApp
  • app
  • isEnvironment
  • isEmployee
  • isLang
  • isModel
  • beginDateTime
  • endDateTime
  • isUpdatableWebView,
  • isResolution,
  • isScreenDensity

License

Smart Assistants

Current Tags

  • 2.0.2                                ...           latest (10 months ago)

26 Versions

  • 2.0.2                                ...           10 months ago
  • 2.0.0                                ...           a year ago
  • 1.0.22 [deprecated]           ...           2 years ago
  • 1.0.21 [deprecated]           ...           2 years ago
  • 1.0.20                                ...           2 years ago
  • 1.0.19                                ...           2 years ago
  • 1.0.18                                ...           2 years ago
  • 1.0.17                                ...           2 years ago
  • 1.0.16                                ...           2 years ago
  • 1.0.15                                ...           2 years ago
  • 1.0.14                                ...           2 years ago
  • 1.0.13                                ...           2 years ago
  • 1.0.1-2.1                                ...           2 years ago
  • 1.0.12                                ...           2 years ago
  • 1.0.11                                ...           2 years ago
  • 1.0.10                                ...           2 years ago
  • 1.0.9                                ...           2 years ago
  • 1.0.8                                ...           2 years ago
  • 1.0.7                                ...           2 years ago
  • 1.0.6                                ...           2 years ago
  • 1.0.5                                ...           2 years ago
  • 1.0.4                                ...           2 years ago
  • 1.0.3                                ...           2 years ago
  • 1.0.2                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Downloads
Today 0
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 1
Dependencies (2)
Dev Dependencies (5)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |