Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
@sheknows/frisbee
Advanced tools
Frisbee is a small cross-browser (IE10+) data collection library. It incorporates a queue and a HTTP client. You define endpoint to hit and keep adding data to Frisbee. Frisbee takes care of the rest.
Load Frisbee
<script src="/frisbee.js"></script>
Instantiate Frisbee
var frisbee = new window.Frisbee({
namespace: 'ns',
url: 'http://foo/bar'
})
Now add some data to it.
frisbee.add(1)
frisbee.add(2)
frisbee.add(3)
frisbee.add(4)
frisbee.add(5)
frisbee.add(6)
Frisbee fills the queue with data until maxItems
is reached (5 by default). At that point, Frisbee removes first 5 items from the queue and POSTs them to the options.url
.
In this example, Frisbee will POST http://foo/bar
with the following request payload:
{
"payload": [1, 2, 3, 4, 5],
"meta": {
"namespace": "ns",
"id": "<instance-specific-uuid>"
}
}
6th item (now 1st) will wait until 4 more are added until another POST. Structure of the request payload can be changed using getRequestData
function. More info below.
Let's add 1 more item.
frisbee.add(1)
Now we have two items waiting. But let's assume that in your app lifecycle at some point(s) you must ensure that the entire queue is drained and POSTed. We can use
frisbee.sendAll()
This will POST http://foo/bar
{
"payload": [6, 1],
"meta": {
"namespace": "ns",
"id": "<instance-specific-uuid>"
}
}
Another use-case for sendAll
method would be setting a timer to periodically POST data regardless of the maxItems
criteria.
{
// Number of items in the queue to reach when the request is made
// Default: 5
maxItems: Number,
// HTTP verb to use for requests
// Default: 'POST'
method: String,
// URL to hit
// Default: undefined
url: String,
// HTTP headers to include
// Default: { 'Content-type': 'application/json; charset=utf-8' }
headers: Object,
// Namespace
// Default: undefined
namespace: [String, Number, Object],
// Transform request payload before the request.
// Runs before every request. This method needs to return a truthy value for request to happen.
// See example in example/scroll.js
// Default:
// function (data, meta) {
// return JSON.stringify({
// payload: data,
// meta: meta
// })
// }
getRequestData: Function
}
getRequestData
wiselydata
Because you have access to data array (of currently emptied queue data), you could append some extra data through this modifier that Frisbee does not know about. Keep in mind that mutating data
will have no effect on subsequent calls to this function since every request works with a fresh set of (different) data.
meta
Mutated meta
object however will carry on for all subsequent getRequestData
calls. Use that your (dis)advantage.
Because request will fire only if this method returns a truthy value, it opens up interesting possibilities. For example, if you want to bundle multiple namespaces into one request, you could create a main frisbee instance to talk to API and bundle several different namespaces while other Frisbee (namespace-specific) instances would be used as queues and never talk to the API, just to the main API Frisbee instance.
FAQs
Data collection transport library
We found that @sheknows/frisbee demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.