Socket
Socket
Sign inDemoInstall

@effection/main

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@effection/main - npm Package Compare versions

Comparing version 2.0.0-v2-writable-unification.1633595877341 to 2.0.0

11

CHANGELOG.md
# @effection/main
## \[2.0.0]
- Release Effection 2.0.0
- [8bd89ad](https://github.com/thefrontside/effection/commit/8bd89ad40e42805ab6da0fd1b7a49beed9769865) Add 2.0 changeset on %as
## \[2.0.0-beta.19]
- Yielding to something which is not an operation no longer throws an internal error, but properly rejects the task.
- Bumped due to a bump in @effection/core.
- [a3ad19a](https://github.com/thefrontside/effection/commit/a3ad19a3177a731fee5cd2389ab898dee7b1788e) Fix yielding non operation bug on 2021-10-07
## \[2.0.0-beta.18]

@@ -4,0 +15,0 @@

@@ -0,1 +1,4 @@

/**
* @hidden
*/
export interface MainErrorOptions {

@@ -5,2 +8,32 @@ exitCode?: number;

}
/**
* Throwing this error inside of an operation running within {@link main}
* is a way to abort the program without causing an error to be printed.
*
* When `main` fails, usually it will print a full stacktrace of the error it
* failed with, but if the error was a `MainError`, the stack trace will not be
* printed. If the optional `message` is given, it is printed instead.
*
* When running in node, the `exitCode` can option can be set to exit with a
* different exit code.
*
* ### Example
*
* ``` typescript
* import { main, MainError } from 'effection';
* import { promises as fs } from 'fs';
*
* const { readFile } = fs;
*
* main(function*() {
* let fileName = process.argv[2];
* try {
* let content = yield readFile(fileName);
* console.log(content.reverse().toString());
* } catch(err) {
* throw new MainError({ message: `no such file ${fileName}`, exitCode: 200 });
* }
* });
* ```
*/
export declare class MainError extends Error {

@@ -11,3 +44,6 @@ name: string;

}
/**
* @hidden
*/
export declare function isMainError(error: Error): error is MainError;
//# sourceMappingURL=error.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isMainError = exports.MainError = void 0;
/**
* Throwing this error inside of an operation running within {@link main}
* is a way to abort the program without causing an error to be printed.
*
* When `main` fails, usually it will print a full stacktrace of the error it
* failed with, but if the error was a `MainError`, the stack trace will not be
* printed. If the optional `message` is given, it is printed instead.
*
* When running in node, the `exitCode` can option can be set to exit with a
* different exit code.
*
* ### Example
*
* ``` typescript
* import { main, MainError } from 'effection';
* import { promises as fs } from 'fs';
*
* const { readFile } = fs;
*
* main(function*() {
* let fileName = process.argv[2];
* try {
* let content = yield readFile(fileName);
* console.log(content.reverse().toString());
* } catch(err) {
* throw new MainError({ message: `no such file ${fileName}`, exitCode: 200 });
* }
* });
* ```
*/
class MainError extends Error {

@@ -12,2 +42,5 @@ constructor(options = {}) {

exports.MainError = MainError;
/**
* @hidden
*/
function isMainError(error) {

@@ -14,0 +47,0 @@ return error.name === 'EffectionMainError';

import { Task, Operation } from '@effection/core';
export * from './error';
/**
* Runs the given operation in a task and returns that task. `main` functions
* as an entry point to programs written in Effection. That means that your
* program should only call `main` once, and everything the program does is
* handled from within `main`. Unlike `run`, `main` automatically prints errors
* that occurred to the console.
*
* Using {@link MainError}, the `main` operation can be aborted without causing
* a stack trace to be printed to the console.
*
* The behaviour of `main` is slightly different depending on the environment it
* is running in.
*
* ### Node
*
* When running within node, any error which reaches `main` causes the entire
* process to exit with an exit code of `1`.
*
* Additionally, handlers for `SIGINT` and `SIGTERM` are attached to the
* process, so that sending an exit signal to the process causes the main task
* to become halted. This means that hitting CTRL-C on an Effection program
* using `main` will cause an orderly shutdown and run all finally blocks and
* ensure operations.
*
* ### Browser
*
* When running in a browser, The `main` operation gets shut down on the
* `unload` event.
*/
export declare function main<T>(operation: Operation<T>): Task<T>;
//# sourceMappingURL=node.d.ts.map

@@ -18,2 +18,31 @@ "use strict";

__exportStar(require("./error"), exports);
/**
* Runs the given operation in a task and returns that task. `main` functions
* as an entry point to programs written in Effection. That means that your
* program should only call `main` once, and everything the program does is
* handled from within `main`. Unlike `run`, `main` automatically prints errors
* that occurred to the console.
*
* Using {@link MainError}, the `main` operation can be aborted without causing
* a stack trace to be printed to the console.
*
* The behaviour of `main` is slightly different depending on the environment it
* is running in.
*
* ### Node
*
* When running within node, any error which reaches `main` causes the entire
* process to exit with an exit code of `1`.
*
* Additionally, handlers for `SIGINT` and `SIGTERM` are attached to the
* process, so that sending an exit signal to the process causes the main task
* to become halted. This means that hitting CTRL-C on an Effection program
* using `main` will cause an orderly shutdown and run all finally blocks and
* ensure operations.
*
* ### Browser
*
* When running in a browser, The `main` operation gets shut down on the
* `unload` event.
*/
function main(operation) {

@@ -20,0 +49,0 @@ return core_1.run(function* (task) {

@@ -0,1 +1,4 @@

/**
* @hidden
*/
export interface MainErrorOptions {

@@ -5,2 +8,32 @@ exitCode?: number;

}
/**
* Throwing this error inside of an operation running within {@link main}
* is a way to abort the program without causing an error to be printed.
*
* When `main` fails, usually it will print a full stacktrace of the error it
* failed with, but if the error was a `MainError`, the stack trace will not be
* printed. If the optional `message` is given, it is printed instead.
*
* When running in node, the `exitCode` can option can be set to exit with a
* different exit code.
*
* ### Example
*
* ``` typescript
* import { main, MainError } from 'effection';
* import { promises as fs } from 'fs';
*
* const { readFile } = fs;
*
* main(function*() {
* let fileName = process.argv[2];
* try {
* let content = yield readFile(fileName);
* console.log(content.reverse().toString());
* } catch(err) {
* throw new MainError({ message: `no such file ${fileName}`, exitCode: 200 });
* }
* });
* ```
*/
export declare class MainError extends Error {

@@ -11,3 +44,6 @@ name: string;

}
/**
* @hidden
*/
export declare function isMainError(error: Error): error is MainError;
//# sourceMappingURL=error.d.ts.map

@@ -0,1 +1,31 @@

/**
* Throwing this error inside of an operation running within {@link main}
* is a way to abort the program without causing an error to be printed.
*
* When `main` fails, usually it will print a full stacktrace of the error it
* failed with, but if the error was a `MainError`, the stack trace will not be
* printed. If the optional `message` is given, it is printed instead.
*
* When running in node, the `exitCode` can option can be set to exit with a
* different exit code.
*
* ### Example
*
* ``` typescript
* import { main, MainError } from 'effection';
* import { promises as fs } from 'fs';
*
* const { readFile } = fs;
*
* main(function*() {
* let fileName = process.argv[2];
* try {
* let content = yield readFile(fileName);
* console.log(content.reverse().toString());
* } catch(err) {
* throw new MainError({ message: `no such file ${fileName}`, exitCode: 200 });
* }
* });
* ```
*/
export class MainError extends Error {

@@ -8,2 +38,5 @@ constructor(options = {}) {

}
/**
* @hidden
*/
export function isMainError(error) {

@@ -10,0 +43,0 @@ return error.name === 'EffectionMainError';

import { Task, Operation } from '@effection/core';
export * from './error';
/**
* Runs the given operation in a task and returns that task. `main` functions
* as an entry point to programs written in Effection. That means that your
* program should only call `main` once, and everything the program does is
* handled from within `main`. Unlike `run`, `main` automatically prints errors
* that occurred to the console.
*
* Using {@link MainError}, the `main` operation can be aborted without causing
* a stack trace to be printed to the console.
*
* The behaviour of `main` is slightly different depending on the environment it
* is running in.
*
* ### Node
*
* When running within node, any error which reaches `main` causes the entire
* process to exit with an exit code of `1`.
*
* Additionally, handlers for `SIGINT` and `SIGTERM` are attached to the
* process, so that sending an exit signal to the process causes the main task
* to become halted. This means that hitting CTRL-C on an Effection program
* using `main` will cause an orderly shutdown and run all finally blocks and
* ensure operations.
*
* ### Browser
*
* When running in a browser, The `main` operation gets shut down on the
* `unload` event.
*/
export declare function main<T>(operation: Operation<T>): Task<T>;
//# sourceMappingURL=node.d.ts.map

@@ -5,2 +5,31 @@ import { run, withLabels } from '@effection/core';

export * from './error';
/**
* Runs the given operation in a task and returns that task. `main` functions
* as an entry point to programs written in Effection. That means that your
* program should only call `main` once, and everything the program does is
* handled from within `main`. Unlike `run`, `main` automatically prints errors
* that occurred to the console.
*
* Using {@link MainError}, the `main` operation can be aborted without causing
* a stack trace to be printed to the console.
*
* The behaviour of `main` is slightly different depending on the environment it
* is running in.
*
* ### Node
*
* When running within node, any error which reaches `main` causes the entire
* process to exit with an exit code of `1`.
*
* Additionally, handlers for `SIGINT` and `SIGTERM` are attached to the
* process, so that sending an exit signal to the process causes the main task
* to become halted. This means that hitting CTRL-C on an Effection program
* using `main` will cause an orderly shutdown and run all finally blocks and
* ensure operations.
*
* ### Browser
*
* When running in a browser, The `main` operation gets shut down on the
* `unload` event.
*/
export function main(operation) {

@@ -7,0 +36,0 @@ return run(function* (task) {

4

package.json
{
"name": "@effection/main",
"version": "2.0.0-v2-writable-unification.1633595877341",
"version": "2.0.0",
"description": "Main entry point for Effection applications",

@@ -31,3 +31,3 @@ "main": "dist-cjs/node.js",

"dependencies": {
"@effection/core": "2.0.0-v2-writable-unification.1633595877341",
"@effection/core": "2.0.0",
"chalk": "^4.1.2",

@@ -34,0 +34,0 @@ "stacktrace-parser": "^0.1.10"

@@ -0,1 +1,4 @@

/**
* @hidden
*/
export interface MainErrorOptions {

@@ -6,2 +9,32 @@ exitCode?: number;

/**
* Throwing this error inside of an operation running within {@link main}
* is a way to abort the program without causing an error to be printed.
*
* When `main` fails, usually it will print a full stacktrace of the error it
* failed with, but if the error was a `MainError`, the stack trace will not be
* printed. If the optional `message` is given, it is printed instead.
*
* When running in node, the `exitCode` can option can be set to exit with a
* different exit code.
*
* ### Example
*
* ``` typescript
* import { main, MainError } from 'effection';
* import { promises as fs } from 'fs';
*
* const { readFile } = fs;
*
* main(function*() {
* let fileName = process.argv[2];
* try {
* let content = yield readFile(fileName);
* console.log(content.reverse().toString());
* } catch(err) {
* throw new MainError({ message: `no such file ${fileName}`, exitCode: 200 });
* }
* });
* ```
*/
export class MainError extends Error {

@@ -18,4 +51,7 @@ name = "EffectionMainError"

/**
* @hidden
*/
export function isMainError(error: Error): error is MainError {
return error.name === 'EffectionMainError';
}

@@ -7,2 +7,31 @@ import { run, withLabels, Task, Operation } from '@effection/core';

/**
* Runs the given operation in a task and returns that task. `main` functions
* as an entry point to programs written in Effection. That means that your
* program should only call `main` once, and everything the program does is
* handled from within `main`. Unlike `run`, `main` automatically prints errors
* that occurred to the console.
*
* Using {@link MainError}, the `main` operation can be aborted without causing
* a stack trace to be printed to the console.
*
* The behaviour of `main` is slightly different depending on the environment it
* is running in.
*
* ### Node
*
* When running within node, any error which reaches `main` causes the entire
* process to exit with an exit code of `1`.
*
* Additionally, handlers for `SIGINT` and `SIGTERM` are attached to the
* process, so that sending an exit signal to the process causes the main task
* to become halted. This means that hitting CTRL-C on an Effection program
* using `main` will cause an orderly shutdown and run all finally blocks and
* ensure operations.
*
* ### Browser
*
* When running in a browser, The `main` operation gets shut down on the
* `unload` event.
*/
export function main<T>(operation: Operation<T>): Task<T> {

@@ -9,0 +38,0 @@ return run(function*(task) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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