New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

es5-async

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

es5-async - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

readme.md

38

dist/async.js

@@ -11,6 +11,7 @@ (function (factory) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class Async {
constructor(async) {
this.ctx = {};
exports.__esModule = true;
var Async = /** @class */ (function () {
function Async(async) {
var _this = this;
this.data = {};
this.closed = false;

@@ -20,23 +21,26 @@ this.zeroPromise = Promise.resolve(null);

this.lastFunctionResult = this.zeroPromise;
this.await = (func) => {
let required_keys = Object.keys(this.ctx);
let newFunctionResult = this.lastFunctionResult.then(() => this.parseCtxPromiseValue(required_keys)).then(() => typeof func === 'function' ? func() : func);
this.lastFunctionResult = newFunctionResult;
this.await = function (func) {
var required_keys = Object.keys(_this.data);
var lastResult;
var newFunctionResult = _this.lastFunctionResult.then(function (_val) { return (lastResult = _val, _this.parseCtxPromiseValue(required_keys)); }).then().then(function () { return typeof func === 'function' ? func(lastResult) : func; });
_this.lastFunctionResult = newFunctionResult;
return newFunctionResult;
};
this.parseCtxPromiseValue = (keys = Object.keys(this.ctx)) => {
return Promise.all(keys.map((key) => this.zeroPromise.then(() => this.ctx[key]))).then((values) => {
values.map((val, index) => {
this.ctx[keys[index]] = val;
this.parseCtxPromiseValue = function (keys) {
if (keys === void 0) { keys = Object.keys(_this.data); }
return Promise.all(keys.map(function (key) { return _this.zeroPromise.then(function () { return _this.data[key]; }); })).then(function (values) {
values.map(function (val, index) {
_this.data[keys[index]] = val;
});
});
};
this.promise = new Promise((finish) => {
async(this.await, this.ctx, (result) => (finish(), result));
}).then(() => this.lastFunctionResult);
this.promise = new Promise(function (finish) {
async(_this.await, _this.data, function (result) { return (finish(), result); });
}).then(function () { return _this.lastFunctionResult; });
}
}
return Async;
}());
exports.Async = Async;
exports.async = (func) => new Async(func).promise;
exports.async = function (func) { return new Async(func).promise; };
});
//# sourceMappingURL=async.js.map
{
"name": "es5-async",
"version": "0.0.1",
"version": "0.0.2",
"description": "",

@@ -5,0 +5,0 @@ "main": "dist/async.js",

@@ -8,7 +8,7 @@ interface await<T=any> {

export class Async {
ctx = {}
data = {}
private closed = false
constructor(async:async){
this.promise = new Promise( (finish)=>{
async(this.await,this.ctx,(result)=>(finish(),result))
async(this.await,this.data,(result)=>(finish(),result))
}).then(()=>this.lastFunctionResult)

@@ -20,13 +20,14 @@ }

await:await = (func)=>{
let required_keys = Object.keys(this.ctx)
let newFunctionResult = this.lastFunctionResult.then(()=>this.parseCtxPromiseValue(required_keys)).then(()=>typeof func === 'function'?func():func)
let required_keys = Object.keys(this.data)
let lastResult
let newFunctionResult = this.lastFunctionResult.then((_val)=>(lastResult=_val,this.parseCtxPromiseValue(required_keys))).then().then(()=>typeof func === 'function'?func(lastResult):func)
this.lastFunctionResult = newFunctionResult
return newFunctionResult
}
parseCtxPromiseValue = ( keys = Object.keys(this.ctx) )=>{
parseCtxPromiseValue = ( keys = Object.keys(this.data) )=>{
return Promise.all(
keys.map((key)=>this.zeroPromise.then(()=>this.ctx[key]))
keys.map((key)=>this.zeroPromise.then(()=>this.data[key]))
).then((values)=>{
values.map((val,index)=>{
this.ctx[keys[index]] = val
this.data[keys[index]] = val
})

@@ -33,0 +34,0 @@ })

{
"compilerOptions": {
"target": "es6",
"target": "es3",
"module": "umd",
"outDir": "./dist",
"lib": [
"es2015.promise",
"es5"
],
"sourceMap": true
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc