createPromiseLogic()

Factory FunctionCreate custom PromiseLogic instance with method name customization

createPromiseLogic() is a factory function used to create custom PromiseLogic instances. Through configuration options, you can customize method names to better fit your project's naming conventions and business requirements.

This feature is particularly suitable for large projects, team collaboration, code refactoring, etc., helping you better organize and manage async logic code.

Syntax

javascript
createPromiseLogic(options?)

Parameters

ParameterTypeDescription
optionsCreatePromiseLogicOptionsConfiguration options for customizing instance behavior and naming

Configuration Option Properties

ParameterTypeDescription
prefixstringMethod name prefix, e.g. "async" will generate asyncAnd, asyncOr, etc.
suffixstringMethod name suffix, e.g. "Logic" will generate andLogic, orLogic, etc.
renameRecord<string, string>Custom rename mapping, e.g. { and: "conjunction", or: "disjunction" }

Return Value

Returns a custom PromiseLogic instance containing configured methods.

PromiseLogicInstance

Behavior

Creation Successful

Successfully creates a custom PromiseLogic instance containing configured methods.

Special Case

The createPromiseLogic method never fails, always returns a valid PromiseLogic instance.

Examples

Basic Usage

Create default PromiseLogic instance

JAVASCRIPT
Loading...

Add Prefix

Create instance with prefixed method names

JAVASCRIPT
Loading...

Add Suffix

Create instance with suffixed method names

JAVASCRIPT
Loading...

Custom Rename

Fully customize method names

JAVASCRIPT
Loading...

Combined Configuration

Combine prefix, suffix, and rename

JAVASCRIPT
Loading...

Real Application

Organize different logic groups in project

JAVASCRIPT
Loading...

Naming Rules

Method Name Generation Rules

Priority Order

  1. 1. First check if there is a custom name in rename configuration
  2. 2. If not, apply prefix + original name + suffix rule
  3. 3. If none configured, use default name

Example

javascript
// Configuration: { prefix: 'async', suffix: 'Logic', rename: { and: 'conjunction' } }

// Generated method names:
// and → asyncConjunctionLogic (rename priority)
// or → asyncOrLogic (prefix + or + suffix)
// xor → asyncXorLogic (prefix + xor + suffix)
// Other methods follow the same pattern...

Important Notes

  • createPromiseLogic is used to create custom PromiseLogic instances, supporting method name customization
  • Can use prefix, suffix, and rename configurations simultaneously, configurations are applied in order
  • Methods not specified in rename will use default naming rules (prefix + original name + suffix)
  • Custom instances have the same functionality and behavior as default PromiseLogic
  • Suitable for projects that need to use different naming conventions in different business scenarios
  • Can be used for code organization, namespace isolation, team standard unification, etc.