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 🙏

© 2026 – Pkg Stats / Ryan Hefner

faceplatform

v0.6.3

Published

requesting utils for face platform

Readme

https://www.npmjs.com/package/faceplatform

If you have no idea what face platform is, you’ve probably come to the wrong place.

这个模块是 FP 的应用层接口封装,需配合内部接口文档使用(主要是确认每个接口要发送的数据格式)。

安装

npm install faceplatform  # 建议 node LTS 版本及以上

使用示例

const fs = require('fs');
const FP = require('faceplatform');

const fp = new FP({
    address: '192.168.10.100',
    version: 'mtx.3',
    auth: {
        name: 'admin',
        password: 'admin'
    },
    request_timeout: 10000
});
/********************************************************************************************
**   构造函数传入的数据可以有以下字段:
**
**  - address: 如 ‘192.168.10.100’, 可选字段, 指大平台 master ip 地址, 默认是 127.0.0.1
**  - version: 如 ‘mtx.2’, 必填字段,必须是 `mtx.2`, `mtx.3`, `pgy` 之一,其他版本待后续更新
**  - auth: 可选字段,可填大平台登录信息,默认是 { name: “admin”, password: “admin” }  (无需md5)
**  - request_timeout: 可选字段, 单位为毫秒, 默认是 60000
********************************************************************************************/

let repoId;

fp.get_repository()       // 获取人像库

    .then(() => {
        for (let repo of fp._r.results) {
            if (repo.name === 'test') {
                repoId = repo.id;
                break;
            }
        }
        console.log('test repo id is ' + repoId);
    })

    // 新建人像库
    .add_repository({ name: "test_repo_2" }, function (err, resp, body) {
        console.log('create reposicoty result:');
        console.log(err);
        console.log(resp.statusCode);
        console.log(body);
    })

    // 上传图片
    .upload_image(fp.w(function () {
        return {
            repository_id: fp._r.id,        // 直接使用上个接口调用的结果
            picture_image_content_base64: fs.readFileSync('test.jpg', 'base64')
        };
    }))

    .then(fp.break)                         // 停止调用

    //  不会被上传
    .upload_image({
        repository_id: repoId,
        picture_image_content_base64: fs.readFileSync('test.jpg', 'base64')
    })

    // 捕获异常
    .catch(err => {
        console.log('catch error: ' + err);
    })

    .exec();            // 每次链式调用从 exec() 结束

如以上示例所示:

  • 接口名字可参考 interfaces.js
  • 接口支持链式调用
  • 传入接口的 object 会被当做 request 请求的 body
  • 接口调用支持传入回调函数
  • 接口调用返回 Promise
  • 接口调用支持传入回调函数的同时返回 Promise
  • 最后一个接口调用必须是 exec
  • exec 可传入一个函数,适合传入回调函数
  • _r 指的是上一个接口的返回数据,但如果要在下一个接口直接调用时访问此对象,需要包在 w 函数中
  • 任意接口均不需要先调用登录接口获取 session_id,这个过程会在内部替你完成并记录
  • 大平台接口返回如果 rtn 不为 0,会被当做错误 reject 出来, 在 catch 方法中可以捕获到
  • break 函数可用于停止某条链式调用
  • 如果要调试,请运行时使用环境变量 DEBUG=faceplatform

TODO

  • test cases
  • examples

CHANGELOG

  • 0.6.3 增加底层 get_alerts 接口
  • 0.6.2 将错误传入 exec 收到的函数
  • 0.6.0 引入 session 池,支持并发
  • 0.5.6 增加 utils,base64 转换及 md5 等
  • 0.5.5 增加 encoding 支持,可保持 binary 响应文件
  • 0.5.4 支持最后调用回调函数
  • 0.5.2 蒲公英支持
  • 0.5.1 DEBUG 支持
  • 0.5.0 引入 session_id 自刷新机制
  • 0.4.0 引入 break 函数