Giter VIP home page Giter VIP logo

data.js's Introduction

#data.js Build Status Built with Grunt license release spm package

data.js 是带有消息通知的数据中心,我称其为会说话的数据。旨在让编程变得简单,世界变得美好。

##用途

  1. 全局数据中心,可以用来存放数据,在不同程序**享。
  2. 将程序的耦合度,变为数据耦合,采用隐式调用风格,发挥js事件风格。

##兼容性

  • node.js 0.10+
  • Safari 6+ (Mac)
  • iOS 5+ Safari
  • Chrome 23+ (Windows, Mac, Android, iOS, Linux, Chrome OS)
  • Firefox 4+ (Windows, Mac, Android, Linux, Firefox OS)
  • Internet Explorer 6+ (Windows, Windows Phone)
  • Opera 10+ (Windows, linux, Android)

##使用方法

###传统方法

//在程序的最开始处添加如下js
<script src="data.js"></script>
<script>
	Data.set('a', 123);
</script>

###AMD

require(['data'], function (Data) {
	Data.set('a', 123);
});

###bower

$ bower install data.js

###spm

$ spm install data.js

###npm

$ npm install data_js
// *.js
var Data = require('data');
Data.set('a', 123);

即可使用data.js,在传统浏览器环境data.js占用全局命名空间 Data

##快速开始

Data常用接口只有三个,非常简单:

Data.sub('set', 'a', function (e) {console.log(e.data)});//订阅消息,当a被设置时,会派发消息

Data.set('a', 1);//存入数据

Data.get('a');//读取数据

更多例子,请见目录下的demo目录。

##文档

API

##测试

data.js的代码运行于ecmascript严格模式下,jshint验证,完整的单元测试,并使用travis保证。测试代码见test目录下。

##性能

data.js的存入和取出,都是对数据的一次深拷贝,同时还要解析数据的键和派发消息,所以性能会有很大损失,但不涉及大批量循环存取不会遇到性能问题。

##贡献代码

如果你想为data.js贡献代码,请采用fork + pull request 方式,并在发起pr前先将master上超前的代码rebase到自己的分支上。

在目录运行如下命令,完成验证测试编译过程,确保无误:

$ npm install #安装grunt及其依赖
$ grunt

##作者

yanhaijing

##报告问题

##版权信息

Copyright © 2013 yanhaijing. All Rights Reserved

Licensed under the MIT-LICENSE; you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at: http://opensource.org/licenses/MIT

data.js's People

Contributors

afc163 avatar justjavac avatar lizheming avatar yanhaijing avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.