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

ajax-data-model

v0.0.12

Published

ajax data model, ajax 通用数据请求处理

Downloads

47

Readme

Ajax-Data-Model

NPM version Dependency Status License Downloads

ajax 数据请求模型封装。在 ajax 请求的生命周期过程中,实现基于项目约定的通用行为操作。

特性

  • umd 支持
  • memory/sessionStorage/localStorage 级数据缓存支持
  • Promise thenable 风格的 API 调用
  • 基于接口约定的通用回调处理支持(通用错误处理、loading 状态、通用参数、埋点上报<接口超时、接口错误、接口异常、数据埋点等>...)

快速开始

1. 下载安装

手动下载:到代码仓库下载 release 的 zip 包,取得 dist 目录内文件即可。

npm 方式:

npm i --save ajax-data-model

2. 使用

2.1 浏览器中直接引用使用

A. 引入 jquery.min.jsadm.jquery.min.js

<script src="lib/jquery/juqery.min.js"></script>
<script src="lib/ajax-data-model/adm.jquery.min.js"></script>

B. 使用

<script>
  var adm = window.adm;

  // 全局性设置
  adm.setSettings({...});

  // 使用
  adm.get({url: '/xxx'}).then((result) => {
    console.log(result);
  });
</script>

2.2 ES6 方式使用

A. 全局性设置

// adm.js
import $ from 'jquery';
import adm from 'ajax-data-model';

// 全局性设置
adm.setSettings({...});

// 示例:注册添加 API 到 adm 上(方便引用)
adm.restapi = {
  userlist: '/rest/user/list'
};
// todo more...

export default adm;

具体可参考 src/common/settings.js 中的参数配置示例。

B. 使用

import adm from './adm';
// 使用示例
adm.get({url: '/xxx'}).then((result) => {
  console.log(result);
});

更多详细用法示例:USEAGE.md

命令脚本与二次开发

  • npm start:开启 3131 端口 web 服务,进行测试开发。
  • npm run dev:开启开发监听模式,监听 src 目录。
  • npm testmocha + chai 测试(需先执行 npm start)。
  • npm run build:构建生产环境使用源码 (mini) 到 lib 目录。
  • npm run jsdoc:生成 jsdoc 风格的 API 文档。

API

请参阅: API

License

ajax-data-model is released under the MIT license.

该插件由志文工作室开发和维护。