Added Js code (40%)
[iotcloud.git] / src / js / iotjs / src / main.js
1 /* jshint devel:true */
2 "use strict";
3 console.log('Welcome to iotjs-www','\n\n');
4
5 // set up the base line..
6 // Using browserify to set up browser exports
7 var crypto = require('crypto-js');
8 var hash = require('object-hash');
9 var _ = require('underscore');
10 var ByteBuffer = require("bytebuffer");
11
12
13 (function() {
14     
15     var root = this;
16
17
18     // iot namespace main constructor
19     var iot = function(obj) {
20         if (obj instanceof iot) return obj;
21         if (!(this instanceof iot)) return new iot(obj);
22         this.iot = obj;
23     };
24     
25     // export iot to the global exports
26     if (typeof exports !== 'undefined') {
27         if (typeof module !== 'undefined' && module.exports) {
28             exports = module.exports = iot;
29         }
30         exports.iot = iot;
31     } else {
32         root.iot = iot;
33     }
34
35     iot.baselinetest = function(){
36         // baseline test
37         console.log('its alive!!!');
38         console.log();
39
40         //local hash test
41         console.log(hash('hello man'));
42         console.log(typeof hash('hello man'));
43         console.log();
44
45         //Pair test
46         var p = new Pair(1,2);
47         console.log(p.toString());
48         console.log();
49
50         //iotstring test
51         var i = new IoTString('hello');
52         console.log(i.length());
53         console.log();
54     }
55
56     
57
58
59
60
61
62
63
64
65
66
67 }())