first
This commit is contained in:
71
node_modules/js-message/Message.js
generated
vendored
Normal file
71
node_modules/js-message/Message.js
generated
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
function Message() {
|
||||
Object.defineProperties(
|
||||
this, {
|
||||
data: {
|
||||
enumerable: true,
|
||||
get: getData,
|
||||
set: setData
|
||||
},
|
||||
type: {
|
||||
enumerable: true,
|
||||
get: getType,
|
||||
set: setType
|
||||
},
|
||||
load:{
|
||||
enumerable:true,
|
||||
writable:false,
|
||||
value:parse
|
||||
},
|
||||
JSON: {
|
||||
enumerable: true,
|
||||
get: getJSON
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
var type = '';
|
||||
var data = {};
|
||||
|
||||
function getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
function getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
function getJSON() {
|
||||
return JSON.stringify(
|
||||
{
|
||||
type: type,
|
||||
data: data
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function setType(value) {
|
||||
type = value;
|
||||
}
|
||||
|
||||
function setData(value) {
|
||||
data = value;
|
||||
}
|
||||
|
||||
function parse(message){
|
||||
try{
|
||||
var message=JSON.parse(message);
|
||||
type=message.type;
|
||||
data=message.data;
|
||||
}catch(err){
|
||||
var badMessage=message;
|
||||
type='error',
|
||||
data={
|
||||
message:'Invalid JSON response format',
|
||||
err:err,
|
||||
response:badMessage
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports=Message;
|
96
node_modules/js-message/README.md
generated
vendored
Normal file
96
node_modules/js-message/README.md
generated
vendored
Normal file
@ -0,0 +1,96 @@
|
||||
# js-message
|
||||
Normalized JS & JSON Message and event Protocol for node.js, vanilla.js (plain old javascript), react.js, websockets, rest api's, node-ipc, and any other protocol that might use a js object and or a JSON string.
|
||||
|
||||
js-message allows for seamless conversion of JSON messages and events to JS objects for a normalized implementation on the server and in the client without needing to concern yourself with JSON intermediaries and custom parsers.
|
||||
|
||||
Things are just easier when you normalize them.
|
||||
|
||||
npm js-message info : [See npm trends and stats for js-message](http://npm-stat.com/charts.html?package=js-message&author=&from=&to=)
|
||||
    
|
||||
|
||||
` npm install --save js-message `
|
||||
|
||||
[](https://github.com/RIAEvangelist)
|
||||
|
||||
GitHub info :
|
||||
[  ](http://riaevangelist.github.io/js-message/)
|
||||
|
||||
[js-message site](http://riaevangelist.github.io/js-message/)
|
||||
|
||||
|
||||
|method or key |type |mutable|description|
|
||||
|---------------|-------|-------|-----------|
|
||||
|type |String |true |the type of message|
|
||||
|data |Object |true |the message data or payload|
|
||||
|load |func |false |load a message from JSON, this will return a message with the type of error if not valid JSON|
|
||||
|JSON |String |not by user|JSON representation of the message|
|
||||
|
||||
### Creating a Message Object
|
||||
|
||||
```javascript
|
||||
|
||||
//commonjs
|
||||
var Message=require('js-message');
|
||||
//plain old javascript
|
||||
<script src='js-message-vanilla.js' />
|
||||
|
||||
var myMessage=new Message;
|
||||
myMessage.type='message or event type';
|
||||
myMessage.data.something='something';
|
||||
myMessage.data.stuff=[1,2,3,4,5]
|
||||
|
||||
console.log(myMessage.JSON);
|
||||
|
||||
```
|
||||
|
||||
### Creating a Message From JSON
|
||||
|
||||
```javascript
|
||||
|
||||
//commonjs
|
||||
var Message=require('js-message');
|
||||
//plain old javascript
|
||||
<script src='js-message-vanilla.js' />
|
||||
|
||||
//lets say we have the above example running on
|
||||
//a websocket server sending js-messages as JSON
|
||||
//
|
||||
//and lets say this is the client in the browser
|
||||
ws.on(
|
||||
'message',
|
||||
handleMessage
|
||||
);
|
||||
|
||||
handleMessage(e){
|
||||
var message=new Message;
|
||||
message.load(e.data);
|
||||
|
||||
console.log(message.type, message.data);
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### Sending a Message Object via WebSocket
|
||||
|
||||
```javascript
|
||||
|
||||
//commonjs
|
||||
var Message=require('js-message');
|
||||
//plain old javascript
|
||||
<script src='js-message-vanilla.js' />
|
||||
|
||||
//client example, but works the same on server too!
|
||||
var ws=new WebSocket('ws://myawesomeWS:8000');
|
||||
|
||||
var myMessage=new Message;
|
||||
myMessage.type='setUsername';
|
||||
myMessage.data.username='sideshow bob';
|
||||
|
||||
ws.send(myMessage.JSON);
|
||||
|
||||
```
|
||||
|
||||
|
||||
---
|
||||
|
||||
This work is licenced via the [DBAD Public Licence](http://www.dbad-license.org/).
|
50
node_modules/js-message/bower.json
generated
vendored
Normal file
50
node_modules/js-message/bower.json
generated
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
{
|
||||
"name": "js-message",
|
||||
"description": "normalized JS Object and JSON message and event protocol for node.js, vanialla js, react.js, components, actions, stores and dispatchers",
|
||||
"main": "Message.js",
|
||||
"authors": [
|
||||
"Brandon Nozaki Miller"
|
||||
],
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"message",
|
||||
"normalize",
|
||||
"events",
|
||||
"js",
|
||||
"json",
|
||||
"protocol",
|
||||
"ipc",
|
||||
"node",
|
||||
"nodejs",
|
||||
"node.js",
|
||||
"react",
|
||||
"react.js",
|
||||
"reactjs",
|
||||
"websocket",
|
||||
"websockets",
|
||||
"web",
|
||||
"socket",
|
||||
"sockets",
|
||||
"ws",
|
||||
"flux",
|
||||
"reflux",
|
||||
"component",
|
||||
"components",
|
||||
"store",
|
||||
"stores",
|
||||
"action",
|
||||
"actions"
|
||||
],
|
||||
"homepage": "https://github.com/RIAEvangelist/js-message",
|
||||
"moduleType": [
|
||||
"globals",
|
||||
"node"
|
||||
],
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
]
|
||||
}
|
75
node_modules/js-message/js-message-vanilla.js
generated
vendored
Normal file
75
node_modules/js-message/js-message-vanilla.js
generated
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
(
|
||||
function(){
|
||||
function Message() {
|
||||
Object.defineProperties(
|
||||
this, {
|
||||
data: {
|
||||
enumerable: true,
|
||||
get: getData,
|
||||
set: setData
|
||||
},
|
||||
type: {
|
||||
enumerable: true,
|
||||
get: getType,
|
||||
set: setType
|
||||
},
|
||||
load:{
|
||||
enumarable:true,
|
||||
writable:false,
|
||||
value:parse
|
||||
},
|
||||
JSON: {
|
||||
enumerable: true,
|
||||
get: getJSON
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
var type = '';
|
||||
var data = {};
|
||||
|
||||
function getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
function getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
function getJSON() {
|
||||
return JSON.stringify(
|
||||
{
|
||||
type: type,
|
||||
data: data
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function setType(value) {
|
||||
type = value;
|
||||
}
|
||||
|
||||
function setData(value) {
|
||||
data = value;
|
||||
}
|
||||
|
||||
function parse(message){
|
||||
try{
|
||||
var message=JSON.parse(message);
|
||||
type=message.type;
|
||||
data=message.data;
|
||||
}catch(err){
|
||||
var badMessage=message;
|
||||
type='error',
|
||||
data={
|
||||
message:'Invalid JSON response format',
|
||||
err:err,
|
||||
response:badMessage
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window.Message=Message;
|
||||
}
|
||||
)();
|
21
node_modules/js-message/licence.md
generated
vendored
Normal file
21
node_modules/js-message/licence.md
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 Brandon Nozaki Miller
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
81
node_modules/js-message/package.json
generated
vendored
Normal file
81
node_modules/js-message/package.json
generated
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
{
|
||||
"_from": "js-message@1.0.7",
|
||||
"_id": "js-message@1.0.7",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-efJLHhLjIyKRewNS9EGZ4UpI8NguuL6fKkhRxVuMmrGV2xN/0APGdQYwLFky5w9naebSZ0OwAGp0G6/2Cg90rA==",
|
||||
"_location": "/js-message",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "js-message@1.0.7",
|
||||
"name": "js-message",
|
||||
"escapedName": "js-message",
|
||||
"rawSpec": "1.0.7",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.0.7"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@achrinza/node-ipc"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/js-message/-/js-message-1.0.7.tgz",
|
||||
"_shasum": "fbddd053c7a47021871bb8b2c95397cc17c20e47",
|
||||
"_spec": "js-message@1.0.7",
|
||||
"_where": "C:\\Users\\zhouxueli\\Desktop\\scheduling-app\\node_modules\\@achrinza\\node-ipc",
|
||||
"author": {
|
||||
"name": "Brandon Nozaki Miller"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/RIAEvangelist/js-message/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {},
|
||||
"deprecated": false,
|
||||
"description": "normalized JS Object and JSON message and event protocol for node.js, vanialla js, react.js, components, actions, stores and dispatchers",
|
||||
"devDependencies": {},
|
||||
"engines": {
|
||||
"node": ">=0.6.0"
|
||||
},
|
||||
"homepage": "https://github.com/RIAEvangelist/js-message#readme",
|
||||
"keywords": [
|
||||
"message",
|
||||
"normalize",
|
||||
"events",
|
||||
"js",
|
||||
"json",
|
||||
"protocol",
|
||||
"ipc",
|
||||
"node",
|
||||
"nodejs",
|
||||
"node.js",
|
||||
"react",
|
||||
"react.js",
|
||||
"reactjs",
|
||||
"websocket",
|
||||
"websockets",
|
||||
"web",
|
||||
"socket",
|
||||
"sockets",
|
||||
"ws",
|
||||
"flux",
|
||||
"reflux",
|
||||
"component",
|
||||
"components",
|
||||
"store",
|
||||
"stores",
|
||||
"action",
|
||||
"actions"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "Message.js",
|
||||
"name": "js-message",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/RIAEvangelist/js-message.git"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "node devServer.js",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"version": "1.0.7"
|
||||
}
|
Reference in New Issue
Block a user