Socket
Socket
Sign inDemoInstall

protoblast

Package Overview
Dependencies
1
Maintainers
1
Versions
101
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.8.15 to 0.8.16

lib/linkedlist.js

9

CHANGELOG.md

@@ -0,1 +1,10 @@

## 0.8.16 (2023-12-21)
* Fix `String#splitOnce(separator)` breaking when the separator is not found
* Add `SeededRng#between(min, max)` method
* Add `emit_chunks` option to server-side `Request` class
* Add `LinkedList` and `LinkedMap` classes
* Allow `Function.timebomb()` to be made with an infinite timeout
* Add `RequestEvents` class, which is similar to `EventSource` but supports `POST` requests
## 0.8.15 (2023-11-27)

@@ -2,0 +11,0 @@

17

lib/function_flow.js

@@ -66,3 +66,3 @@ const defStat = Blast.createStaticDefiner('Function');

* @since 0.1.4
* @version 0.8.11
* @version 0.8.16
*

@@ -83,3 +83,3 @@ * @param {Number} timer Time in ms to wait before exploding

function explode() {
const explode = () => {
var err = new Error('Timeout of ' + timer + 'ms was reached');

@@ -94,8 +94,15 @@

}
}
};
const createTimeout = () => {
// Set the timeout, but only if it's a finite number
if (isFinite(timer)) {
return setTimeout(explode, timer);
}
};
let bomb = {
defused: false,
exploded: false,
handle: setTimeout(explode, timer),
handle: createTimeout(),
defuse: function defuse() {

@@ -119,3 +126,3 @@

clearTimeout(bomb.handle);
bomb.handle = setTimeout(explode, timer);
bomb.handle = createTimeout();

@@ -122,0 +129,0 @@ return true;

@@ -417,4 +417,5 @@ module.exports = function BlastInitLoader(modifyPrototype) {

'Object',
'Array',
'LinkedList',
'LruCache',
'Array',
'Crypto',

@@ -1583,2 +1584,4 @@ 'Date',

Blast.require('request_events', {add_wrapper: true, client: true});
// Now create bound methods

@@ -1585,0 +1588,0 @@ Collection.Object.each(Collection, function eachCollection(StaticClass, className) {

@@ -53,3 +53,3 @@ /**

*/
get(key, value) {
get(key) {

@@ -56,0 +56,0 @@ if(this.#cache.has(key)) {

@@ -83,3 +83,3 @@ var Request = Classes.Develry.Request,

* @since 0.6.2
* @version 0.8.15
* @version 0.8.16
*

@@ -90,5 +90,7 @@ * @return {Pledge}

var that = this,
pledge = new Classes.Pledge.Swift(),
const that = this;
let pledge = new Classes.Pledge.Swift(),
method = this.method_info,
last_chunk_length = 0,
temp_timeout,

@@ -153,10 +155,16 @@ response,

let data_timeout;
if (this.timeout) {
timeout = this.timeout;
} else {
timeout = Math.max(Blast.state.rtt_timeout + 500, this.max_timeout);
data_timeout = timeout = this.timeout;
} else if (this.timeout !== false) {
data_timeout = timeout = Math.max(Blast.state.rtt_timeout + 500, this.max_timeout);
}
if (this.data_timeout != null) {
data_timeout = this.data_timeout;
}
// Create a timeout checker
bomb = Fn.timebomb(timeout, function onTimeout() {
bomb = Fn.timebomb(data_timeout, function onTimeout() {

@@ -219,2 +227,17 @@ if (error || finished) {

if (that.emit_chunks) {
let new_chunk_length = xhr.responseText.length;
if (new_chunk_length != last_chunk_length) {
let chunk = xhr.responseText.slice(last_chunk_length);
last_chunk_length = new_chunk_length;
if (chunk) {
that.emit('chunk', chunk);
}
}
bomb.reset();
}
Blast.state.reportSuccess('readystatechange', event);

@@ -327,4 +350,10 @@ });

// Always get the response as a blob
xhr.responseType = 'blob';
if (this.emit_chunks) {
// If chunks have to be emitted (because it is an event stream)
// the response type has to be text
xhr.responseType = 'text';
} else {
// Always get the response as a blob
xhr.responseType = 'blob';
}

@@ -470,2 +499,18 @@ // Set the ajax header

/**
* Close the connection
*
* @author Jelle De Loecker <jelle@elevenways.be>
* @since 0.8.16
* @version 0.8.16
*/
Request.setMethod(function abort() {
this.cancelled = true;
if (this.xhr) {
return this.xhr.abort();
}
});
/**
* Hook into the original open method

@@ -472,0 +517,0 @@ *

@@ -175,3 +175,3 @@ var dns_cache,

* @since 0.2.0
* @version 0.8.15
* @version 0.8.16
*/

@@ -274,12 +274,17 @@ Request.setMethod(function _make_request(options) {

let timeout;
let data_timeout,
timeout;
if (this.timeout) {
timeout = this.timeout;
} else {
timeout = this.max_timeout;
data_timeout = timeout = this.timeout;
} else if (this.timeout !== false) {
data_timeout = timeout = this.max_timeout;
}
if (this.data_timeout != null) {
data_timeout = this.data_timeout;
}
// Create a timeout checker
let bomb = Fn.timebomb(timeout, function onTimeout() {
let bomb = Fn.timebomb(data_timeout, function onTimeout() {

@@ -352,3 +357,10 @@ if (finished) {

output.on('data', function gotData(data) {
body += data.toString('utf-8');
let text = data.toString('utf-8');
body += text;
if (that.emit_chunks) {
that.emit('chunk', text);
}
bomb.reset();
});

@@ -451,2 +463,18 @@

/**
* Close the connection
*
* @author Jelle De Loecker <jelle@elevenways.be>
* @since 0.8.16
* @version 0.8.16
*/
Request.setMethod(function abort() {
this.cancelled = true;
if (this.outgoing_req) {
return this.outgoing_req.abort();
}
});
/**
* Handle server-side form data submission

@@ -453,0 +481,0 @@ *

@@ -332,3 +332,3 @@ const ORIGINAL_REQUEST = Symbol('ori_req'),

* @since 0.6.2
* @version 0.7.5
* @version 0.8.16
*/

@@ -338,7 +338,8 @@ Request.setMethod(function setOptions(options) {

if (!options) {
return;
return false;
}
if (typeof options == 'string' || Blast.Classes.RURL.isUrl(options)) {
return this.setUrl(options);
this.setUrl(options);
return true;
} else if (options.url || options.href) {

@@ -395,2 +396,3 @@ this.setUrl(options.url || options.href);

return true;
});

@@ -397,0 +399,0 @@

@@ -115,2 +115,33 @@ /**

/**
* Get a number between the given min and max (inclusive)
*
* @author Jelle De Loecker <jelle@develry.be>
* @since 0.8.16
* @version 0.8.16
*
* @return {Number}
*/
Seeded.setMethod(function between(min, max) {
if (typeof max === 'undefined') {
if (typeof min === 'undefined') {
max = 100;
} else {
max = min;
}
min = 0;
}
if (min > max) {
let tmp = min;
min = max;
max = tmp;
}
return Math.floor(this.random()*(max-min+1)+min);
});
/**
* Get the next random number

@@ -117,0 +148,0 @@ *

@@ -52,2 +52,12 @@ module.exports = function serverFunctions(Blast, extras) {

if (options.create_source_map || options.debug) {
if (options.depropertize == null) {
options.depropertize = false;
}
if (options.destringify == null) {
options.destringify = false;
}
}
if (options.depropertize == null || options.depropertize === true) {

@@ -54,0 +64,0 @@ options.depropertize = {};

@@ -414,3 +414,3 @@ const defStat = Blast.createStaticDefiner('String'),

* @since 0.3.8
* @version 0.3.8
* @version 0.8.16
*

@@ -423,4 +423,8 @@ * @param {String} separator

var index = this.indexOf(separator);
let index = this.indexOf(separator);
if (index == -1) {
return [this];
}
return [

@@ -427,0 +431,0 @@ this.substr(0, index),

{
"name": "protoblast",
"description": "Native object expansion library",
"version": "0.8.15",
"version": "0.8.16",
"author": "Jelle De Loecker <jelle@elevenways.be>",

@@ -6,0 +6,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc