@adt/json-rpc
Advanced tools
Comparing version 0.0.1-SNAPSHOT.12 to 0.0.1-SNAPSHOT.13
@@ -213,2 +213,64 @@ 'use strict'; | ||
/** | ||
* UUID | ||
* @constructor | ||
*/ | ||
function UUID(uuid) { | ||
return Object.create(UUID.prototype,/** @lends UUID.prototype */ { | ||
value : { value : uuid, writable : true}, | ||
serialize : {value : function() { | ||
const val = this.value; | ||
return [ | ||
val[0] + val[1], | ||
val[2], | ||
val[3], | ||
val[4], | ||
val[5] + val[6] + val[7]].join("-"); | ||
}} | ||
}); | ||
} | ||
UUID.randomUUID = function () { | ||
return UUID(guid()); | ||
}; | ||
UUID.fromString = function(str) { | ||
const replaced = str.replace(/-/g,""); | ||
const a = []; | ||
for(let i=0;i<32;i+=4){ | ||
a.push(replaced.slice(i,i+4)); | ||
} | ||
return UUID(a); | ||
}; | ||
/** | ||
* Helper function | ||
* @returns {String} | ||
*/ | ||
function s4() { | ||
return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1); | ||
} | ||
/** | ||
* Helper function | ||
* @return {Array} | ||
*/ | ||
function guid() { | ||
const ar=[]; | ||
for(let i=0;i<8;i++){ | ||
ar.push(s4()); | ||
} | ||
return ar; | ||
} | ||
/** | ||
* JSON-RPC Request | ||
@@ -231,4 +293,3 @@ * TODO: Maybe length of 'method' parameter should be checked? Specification does not say anything about empty string as method name | ||
//this.id = "id" in o ? o.id : UUID.randomUUID().serialize(); | ||
const id = "id" in o ? o.id : 1; | ||
const id = "id" in o ? o.id : UUID.randomUUID(); | ||
@@ -235,0 +296,0 @@ return Object.freeze(Object.create(JsonRpcRequest.prototype,/** @lends JsonRpcRequest.prototype */ { |
@@ -209,2 +209,64 @@ /** | ||
/** | ||
* UUID | ||
* @constructor | ||
*/ | ||
function UUID(uuid) { | ||
return Object.create(UUID.prototype,/** @lends UUID.prototype */ { | ||
value : { value : uuid, writable : true}, | ||
serialize : {value : function() { | ||
const val = this.value; | ||
return [ | ||
val[0] + val[1], | ||
val[2], | ||
val[3], | ||
val[4], | ||
val[5] + val[6] + val[7]].join("-"); | ||
}} | ||
}); | ||
} | ||
UUID.randomUUID = function () { | ||
return UUID(guid()); | ||
}; | ||
UUID.fromString = function(str) { | ||
const replaced = str.replace(/-/g,""); | ||
const a = []; | ||
for(let i=0;i<32;i+=4){ | ||
a.push(replaced.slice(i,i+4)); | ||
} | ||
return UUID(a); | ||
}; | ||
/** | ||
* Helper function | ||
* @returns {String} | ||
*/ | ||
function s4() { | ||
return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1); | ||
} | ||
/** | ||
* Helper function | ||
* @return {Array} | ||
*/ | ||
function guid() { | ||
const ar=[]; | ||
for(let i=0;i<8;i++){ | ||
ar.push(s4()); | ||
} | ||
return ar; | ||
} | ||
/** | ||
* JSON-RPC Request | ||
@@ -227,4 +289,3 @@ * TODO: Maybe length of 'method' parameter should be checked? Specification does not say anything about empty string as method name | ||
//this.id = "id" in o ? o.id : UUID.randomUUID().serialize(); | ||
const id = "id" in o ? o.id : 1; | ||
const id = "id" in o ? o.id : UUID.randomUUID(); | ||
@@ -231,0 +292,0 @@ return Object.freeze(Object.create(JsonRpcRequest.prototype,/** @lends JsonRpcRequest.prototype */ { |
@@ -221,2 +221,64 @@ (function (global, factory) { | ||
/** | ||
* UUID | ||
* @constructor | ||
*/ | ||
function UUID(uuid) { | ||
return Object.create(UUID.prototype,/** @lends UUID.prototype */ { | ||
value : { value : uuid, writable : true}, | ||
serialize : {value : function() { | ||
const val = this.value; | ||
return [ | ||
val[0] + val[1], | ||
val[2], | ||
val[3], | ||
val[4], | ||
val[5] + val[6] + val[7]].join("-"); | ||
}} | ||
}); | ||
} | ||
UUID.randomUUID = function () { | ||
return UUID(guid()); | ||
}; | ||
UUID.fromString = function(str) { | ||
const replaced = str.replace(/-/g,""); | ||
const a = []; | ||
for(let i=0;i<32;i+=4){ | ||
a.push(replaced.slice(i,i+4)); | ||
} | ||
return UUID(a); | ||
}; | ||
/** | ||
* Helper function | ||
* @returns {String} | ||
*/ | ||
function s4() { | ||
return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1); | ||
} | ||
/** | ||
* Helper function | ||
* @return {Array} | ||
*/ | ||
function guid() { | ||
const ar=[]; | ||
for(let i=0;i<8;i++){ | ||
ar.push(s4()); | ||
} | ||
return ar; | ||
} | ||
/** | ||
* JSON-RPC Request | ||
@@ -239,4 +301,3 @@ * TODO: Maybe length of 'method' parameter should be checked? Specification does not say anything about empty string as method name | ||
//this.id = "id" in o ? o.id : UUID.randomUUID().serialize(); | ||
const id = "id" in o ? o.id : 1; | ||
const id = "id" in o ? o.id : UUID.randomUUID(); | ||
@@ -243,0 +304,0 @@ return Object.freeze(Object.create(JsonRpcRequest.prototype,/** @lends JsonRpcRequest.prototype */ { |
{ | ||
"name": "@adt/json-rpc", | ||
"version": "0.0.1-SNAPSHOT.12", | ||
"version": "0.0.1-SNAPSHOT.13", | ||
"license": "MIT", | ||
@@ -27,3 +27,12 @@ "main": "dist/JsonRpc.cjs.js", | ||
"dist" | ||
], | ||
"keywords": [ | ||
"jsonrpc", | ||
"json", | ||
"rpc", | ||
"remote", | ||
"procedure", | ||
"call", | ||
"request-response" | ||
] | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32569
915