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

yc-fam-js

v1.1.4

Published

孕橙 FAM 算法 JavaScript SDK

Downloads

51

Readme

YunCheng FAM Algorithm Document

English | 简体中文

Installing & Updating

Installing by npm:

$ npm install yc-fam-js

Updating by npm:

$ npm update yc-fam-js

Algorithm Request Example

Node & Browser

See https://github.com/iKangtai/yc-fam-js-demo.git

yc-fam-js API

FAM class define

class YCFam {
  /**
   * Get a FAM Algorithm instance
   * @param {String} appId App Id, get from YunCheng
   * @param {String} appSecret App Secret, get from YunCheng
   * @param {String} unionId A unique Id for user of App
   */
  constructor(appId, appSecret, unionId)
}

Start a FAM algorithm request

/**
 * Call FAM Algorithm
 * @param {String} debugId UUID
 * @param {Object} input The input data for algorithm
 * @returns {Promise} Return algorithm results
 */
getFAMDays(debugId, input)

Algorithm Data

Input

{
  debug: 0, // Debug or not, default is 0
  param: { version: 1 }, // Version, 1
  userData: // User Data, Object
  {
    userAverageCycleLength: 28, // Average cycle length, default is 28, required
    userCycleLengthError: 0, // Cycle length error, default is 0, optional
    userCycleRegularity: 1, // 周期是否规律,0 不规律,1 规律,默认 1
    userAverageMenstruationLength: 5, // 平均经期长度,整数,单位 天,默认 5,必填
    userAverageLuteumLength: 14 // 平均黄体期长度,整数,单位 天,默认 14
  },
  daysInput: // 用户输入的 “经期、BBT、排卵日” 等数据,以天为单位,一天一条,Array
  [
    {
      impactTempFlag: 0, // 当天是否有 “发烧、熬夜” 等影响基础体温的情况,1 有,0 没有,默认 0
      BBT: 36.54, // 当天的基础体温,0 表示当天没有测温,默认 0,单位为 ℃,类型为 float
      ovulationResultByUser: 0, // 用户是否标记当天为排卵日,1 标记了,0 未标记,默认 0
      ovulationResultByLH: 0, // 当天是否是 LH 试纸确认的排卵日,1 是,0 不是,默认 0
      cervicalMunusRecord: 0, // 当天的宫颈粘液打分,打分标准见备注,默认 0
      timestamp: 1461902400, // 当天的时间戳,注意其时分秒需要设置为 12:00:00,必填
      dayOfCycle: 0, // 已废弃,不需要填写
      menstruationRecord: 10 // 经期记录,注意:算法不区分开始和结束。取值说明见备注,默认 0
    },
    ...
  ]
}

Comments:

  • cervicalMunusRecord 宫颈粘液打分说明
    • 无数据:0
    • 干燥:1
    • 潮湿:2
    • 粘稠:3
    • 蛋清/水状:4
  • menstruationRecord 经期记录取值说明
    • 无数据:0
    • 经期流血:10 注意:如果用户输入的是 “经期开始和结束”,在调用算法的时候,只需要把开始和结束内的日期都标记成 10 即可

Output

{
  code: 200, // 返回码,详细说明见备注
  message: "success", // 返回码对应的信息
  data: { // 用于存放返回的算法结果,Object
    daysOutput: [ // 算法返回的具体信息,以天为单位,一天一条,Array
      {
        pa: 1, // 当天所处的时段,详细说明见备注
        date: 1461902400, // 当天的时间戳,正常情况下为当天的 12:00:00(需要控制算法输入的 timestamp)
        cd: 1 // 当天处于周期的第几天
      },
      ...
    ]
  }
}

备注:

  • code 返回码的说明
    • 200:没有错误,正常返回
    • 40005:时间戳错误
    • 40201:传入参数有问题,json 无法解析
    • 40251:dayInput 为空
    • 40252:没有经期记录
    • 40401:day 数据非法
  • pa 当天所处时段的说明
    • 1:经期
    • 2:卵泡期
    • 3:排卵期
    • 4:排卵日
    • 5:黄体期

Promises

yc-fam-js depends on a native ES6 Promise implementation to be supported. If your environment doesn't support ES6 Promises, you can polyfill.

License

MIT