1612602600
JSON-RPC 2.0 library with WebSockets and HTTP support for deno and the browser.
This library is accessible through the https://deno.land/x/ service or through https://nest.land/package/gentle_rpc.
Takes a req
, methods
and options
. You can set options for an additional server argument or public error stacks.
import { serve } from "https://deno.land/std@0.84.0/http/server.ts"
import { respond } from "https://deno.land/x/gentle_rpc/mod.ts"
const s = serve("0.0.0.0:8000")
console.log("listening on 0.0.0.0:8000")
const rpcMethods = {
sayHello: (w: [string]) => `Hello ${w}`,
callNamedParameters: ({ a, b, c }: { a: number; b: number; c: string }) =>
`${c} ${a * b}`,
animalsMakeNoise: (noise: [string]) =>
noise.map((el) => el.toUpperCase()).join(" "),
}
for await (const req of s) {
// HTTP:
await respond(req, rpcMethods)
// WebSockets:
await respond(req, rpcMethods, { proto: "ws" })
}
Takes a resource
for HTTP or a WebSocket
for WebSockets and returns a TypeScript Proxy
or Promise<Proxy>
which we will call remote
from now on.
import { createRemote } from "https://deno.land/x/gentle_rpc/mod.ts"
// HTTP:
const remote = createRemote("http://0.0.0.0:8000")
// WebSocket:
const remote = await createRemote(new WebSocket("ws://0.0.0.0:8000"))
All remote
methods take an Array<JsonValue>
or Record<string, JsonValue>
object and return Promise<JsonValue | undefined>
.
const greeting = await remote.sayHello(["World"])
// Hello World
const namedParams = await remote.callNamedParameters({
a: 5,
b: 10,
c: "result:",
})
// result: 50
const notification = await remote.sayHello.notify(["World"])
// undefined
This method will set the Authorization
header to Bearer ${jwt}
.
const greeting = await remote.sayHello.auth(jwt)(["World"])
// Hello World
const noise1 = await remote.animalsMakeNoise.batch([
["miaaow"],
["wuuuufu", "wuuuufu"],
["iaaaiaia", "iaaaiaia", "iaaaiaia"],
["fiiiiire"],
])
// [ "MIAAOW", "WUUUUFU WUUUUFU", "IAAAIAIA IAAAIAIA IAAAIAIA", "FIIIIIRE" ]
Takes either a batchObject
or a batchArray
as argument and returns a promise.
await remote.batch({
cat: ["sayHello", ["miaaow"]],
dog: ["animalsMakeNoise", ["wuuuufu"]],
donkey: ["sayHello"],
dragon: ["animalsMakeNoise", ["fiiiiire", "fiiiiire"]],
})
// { cat: "Hello miaaow", dog: "WUUUUFU", donkey: "Hello ", dragon: "FIIIIIRE FIIIIIRE" }
The example above uses the object keys cat
, dog
, donkey
, dragon
as RPC request object ids under the hood. The returned RPC result values will be assigned to these keys.
For other use cases you might prefer the following example:
await remote.batch([
"animalsMakeNoise",
["miaaow"],
["wuuuufu", "wuuuufu"],
["iaaaiaia", "iaaaiaia", "iaaaiaia"],
["fiiiiire"],
])
// [ "MIAAOW", "WUUUUFU WUUUUFU", "IAAAIAIA IAAAIAIA IAAAIAIA", "FIIIIIRE" ]
The support for WebSockets is still experimental and has not been fully tested yet.
All remote
methods take an Array<JsonValue>
or Record<string, JsonValue>
object and return Promise<JsonValue | undefined>
.
const noise = await remote.animalsMakeNoise(["wuufff"])
console.log(noise)
remote.socket.close()
const notification = await remote.animalsMakeNoise.notify(["wuufff"])
By using the subscribe
method you can send messages between multiple clients. It returns an object with a generator property { generator: AsyncGenerator<JsonValue>}
and the methods emit
, emitBatch
and unsubscribe
.
Other clients can listen to and emit messages by subscribing to the same method.
// First client
export async function run(iter: AsyncGenerator<unknown>) {
try {
for await (let x of iter) {
console.log(x)
}
} catch (err) {
console.log(err.message, err.code)
}
}
const greeting = remote.sayHello.subscribe()
run(greeting.generator)
greeting.emit(["first"])
// Hello first
// Hello second
// Hello third
// Second client
const greeting = remote.sayHello.subscribe()
run(greeting.generator)
greeting.emitBatch([["second"], ["third"]])
// Hello first
// Hello second
// Hello third
// You can optionally unsubscribe:
greeting.unsubscribe()
Checkout the examples and tests folders for more detailed examples.
Every kind of contribution to this project is highly appreciated.
Please run deno fmt
on the changed files before making a pull request.
Author: timonson
Source Code: https://github.com/timonson/gentle_rpc
#deno #nodejs #node #javascript
1626067800
Today in this post i will show you How to Check User Browser is Supported or Not in jQuery.
Some time latest features are not supported in many browser like internet explorer,safari, google chrome etc,So in this post i will show you How to Detect User Browser and using this How to Check User Browser is Supported or Not in jQuery.
#how to check user browser is supported or not in jquery #browser #jquery #how to detect user browser #chrome #safari
1612602600
JSON-RPC 2.0 library with WebSockets and HTTP support for deno and the browser.
This library is accessible through the https://deno.land/x/ service or through https://nest.land/package/gentle_rpc.
Takes a req
, methods
and options
. You can set options for an additional server argument or public error stacks.
import { serve } from "https://deno.land/std@0.84.0/http/server.ts"
import { respond } from "https://deno.land/x/gentle_rpc/mod.ts"
const s = serve("0.0.0.0:8000")
console.log("listening on 0.0.0.0:8000")
const rpcMethods = {
sayHello: (w: [string]) => `Hello ${w}`,
callNamedParameters: ({ a, b, c }: { a: number; b: number; c: string }) =>
`${c} ${a * b}`,
animalsMakeNoise: (noise: [string]) =>
noise.map((el) => el.toUpperCase()).join(" "),
}
for await (const req of s) {
// HTTP:
await respond(req, rpcMethods)
// WebSockets:
await respond(req, rpcMethods, { proto: "ws" })
}
Takes a resource
for HTTP or a WebSocket
for WebSockets and returns a TypeScript Proxy
or Promise<Proxy>
which we will call remote
from now on.
import { createRemote } from "https://deno.land/x/gentle_rpc/mod.ts"
// HTTP:
const remote = createRemote("http://0.0.0.0:8000")
// WebSocket:
const remote = await createRemote(new WebSocket("ws://0.0.0.0:8000"))
All remote
methods take an Array<JsonValue>
or Record<string, JsonValue>
object and return Promise<JsonValue | undefined>
.
const greeting = await remote.sayHello(["World"])
// Hello World
const namedParams = await remote.callNamedParameters({
a: 5,
b: 10,
c: "result:",
})
// result: 50
const notification = await remote.sayHello.notify(["World"])
// undefined
This method will set the Authorization
header to Bearer ${jwt}
.
const greeting = await remote.sayHello.auth(jwt)(["World"])
// Hello World
const noise1 = await remote.animalsMakeNoise.batch([
["miaaow"],
["wuuuufu", "wuuuufu"],
["iaaaiaia", "iaaaiaia", "iaaaiaia"],
["fiiiiire"],
])
// [ "MIAAOW", "WUUUUFU WUUUUFU", "IAAAIAIA IAAAIAIA IAAAIAIA", "FIIIIIRE" ]
Takes either a batchObject
or a batchArray
as argument and returns a promise.
await remote.batch({
cat: ["sayHello", ["miaaow"]],
dog: ["animalsMakeNoise", ["wuuuufu"]],
donkey: ["sayHello"],
dragon: ["animalsMakeNoise", ["fiiiiire", "fiiiiire"]],
})
// { cat: "Hello miaaow", dog: "WUUUUFU", donkey: "Hello ", dragon: "FIIIIIRE FIIIIIRE" }
The example above uses the object keys cat
, dog
, donkey
, dragon
as RPC request object ids under the hood. The returned RPC result values will be assigned to these keys.
For other use cases you might prefer the following example:
await remote.batch([
"animalsMakeNoise",
["miaaow"],
["wuuuufu", "wuuuufu"],
["iaaaiaia", "iaaaiaia", "iaaaiaia"],
["fiiiiire"],
])
// [ "MIAAOW", "WUUUUFU WUUUUFU", "IAAAIAIA IAAAIAIA IAAAIAIA", "FIIIIIRE" ]
The support for WebSockets is still experimental and has not been fully tested yet.
All remote
methods take an Array<JsonValue>
or Record<string, JsonValue>
object and return Promise<JsonValue | undefined>
.
const noise = await remote.animalsMakeNoise(["wuufff"])
console.log(noise)
remote.socket.close()
const notification = await remote.animalsMakeNoise.notify(["wuufff"])
By using the subscribe
method you can send messages between multiple clients. It returns an object with a generator property { generator: AsyncGenerator<JsonValue>}
and the methods emit
, emitBatch
and unsubscribe
.
Other clients can listen to and emit messages by subscribing to the same method.
// First client
export async function run(iter: AsyncGenerator<unknown>) {
try {
for await (let x of iter) {
console.log(x)
}
} catch (err) {
console.log(err.message, err.code)
}
}
const greeting = remote.sayHello.subscribe()
run(greeting.generator)
greeting.emit(["first"])
// Hello first
// Hello second
// Hello third
// Second client
const greeting = remote.sayHello.subscribe()
run(greeting.generator)
greeting.emitBatch([["second"], ["third"]])
// Hello first
// Hello second
// Hello third
// You can optionally unsubscribe:
greeting.unsubscribe()
Checkout the examples and tests folders for more detailed examples.
Every kind of contribution to this project is highly appreciated.
Please run deno fmt
on the changed files before making a pull request.
Author: timonson
Source Code: https://github.com/timonson/gentle_rpc
#deno #nodejs #node #javascript
1621223780
Magento is the best cross-platform framework that helps you to develop the best eCommerce web apps. It is important to maintain your Magento eCommerce web app to increase the performance of your web application.
Magento maintenance and support services play a vital role in maintaining the website because if the website or web app is not maintained properly it can create bugs in the future and many more problems can occur through which there is a chance that customers get frustrated and won’t visit your website again.
Nevina Infotech is the best choice for Magento maintenance and service of your web apps. We have a hardworking team of developers that will help you to increase the performance of your web apps.
#magento maintenance and support services #magento support services #magento support and maintenance #magento support #magento maintenance support #magento technical support
1618806778
Magento is the most demanded technology for developing online eCommerce stores and Magento service is important for better working of the online store. Nevina Infotech provides you with Magento maintenance and services.
Magento maintenance is the process of checking the performance of the website and checking the regular updates, backups, online store management, and much more.
You can choose Nevina Infotech for Magento maintenance service for your eCommerce store. We provide the best Magento support and maintenance for eCommerce stores.
#magento maintenance and support services #magento support services #magento support and maintenance #magento support #magento maintenance support #magento technical support
1626851156
Are you tired of outdated features in your eCommerce app and do you want some latest and trending features in your eCommerce app? Then you need to update your app regularly to stay updated with the latest and trending features to add to your app. For updating it you need to update to the latest version of the Magento so that whatever update occurs in the latest version can also occur in your eCommerce app.
You can hire Nevina Infotech that can help you to provide Magento support and maintenance and will also guide you to update your eCommerce app for adding the latest features to your app. Our team is great and enthusiastic about their work. You can easily rely on us to get the latest features in your eCommerce app.
#magento maintenance and support services #magento support services #magento support and maintenance #magento support #magento maintenance support #magento technical support