Options
All
  • Public
  • Public/Protected
  • All
Menu

A Promise proxy for the result of PostCSS transformations.

A LazyResult instance is returned by Processor#process.

const lazy = postcss([autoprefixer]).process(css)

Type parameters

Hierarchy

  • LazyResult_

Implements

Implemented by

Index

Constructors

  • Type parameters

    Parameters

    • processor: Processor_

      Processor used for this transformation.

    • css: string

      CSS to parse and transform.

    • opts: ResultOptions

      Options from the Processor#process or Root#toResult.

    Returns LazyResult_<RootNode>

Properties

catch: <TResult>(onrejected?: null | ((reason: any) => TResult | PromiseLike<TResult>)) => Promise<Result_<RootNode> | TResult>

Type declaration

    • <TResult>(onrejected?: null | ((reason: any) => TResult | PromiseLike<TResult>)): Promise<Result_<RootNode> | TResult>
    • Attaches a callback for only the rejection of the Promise.

      It implements standard Promise API.

      postcss([autoprefixer]).process(css).then(result => {
      console.log(result.css)
      }).catch(error => {
      console.error(error)
      })

      Type parameters

      • TResult = never

      Parameters

      • Optional onrejected: null | ((reason: any) => TResult | PromiseLike<TResult>)

        The callback to execute when the Promise is rejected.

      Returns Promise<Result_<RootNode> | TResult>

      A Promise for the completion of the callback.

finally: (onfinally?: null | (() => void)) => Promise<Result_<RootNode>>

Type declaration

    • (onfinally?: null | (() => void)): Promise<Result_<RootNode>>
    • Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The resolved value cannot be modified from the callback.

      It implements standard Promise API.

      postcss([autoprefixer]).process(css).finally(() => {
      console.log('processing ended')
      })

      Parameters

      • Optional onfinally: null | (() => void)

        The callback to execute when the Promise is settled (fulfilled or rejected).

      Returns Promise<Result_<RootNode>>

      A Promise for the completion of the callback.

then: <TResult1, TResult2>(onfulfilled?: null | ((value: Result_<RootNode>) => TResult1 | PromiseLike<TResult1>), onrejected?: null | ((reason: any) => TResult2 | PromiseLike<TResult2>)) => Promise<TResult1 | TResult2>

Type declaration

    • <TResult1, TResult2>(onfulfilled?: null | ((value: Result_<RootNode>) => TResult1 | PromiseLike<TResult1>), onrejected?: null | ((reason: any) => TResult2 | PromiseLike<TResult2>)): Promise<TResult1 | TResult2>
    • Attaches callbacks for the resolution and/or rejection of the Promise.

      It implements standard Promise API.

      postcss([autoprefixer]).process(css, { from: cssPath }).then(result => {
      console.log(result.css)
      })

      Type parameters

      • TResult1 = Result_<RootNode>

      • TResult2 = never

      Parameters

      • Optional onfulfilled: null | ((value: Result_<RootNode>) => TResult1 | PromiseLike<TResult1>)

        The callback to execute when the Promise is resolved.

      • Optional onrejected: null | ((reason: any) => TResult2 | PromiseLike<TResult2>)

        The callback to execute when the Promise is rejected.

      Returns Promise<TResult1 | TResult2>

      A Promise for the completion of which ever callback is executed.

Accessors

  • get [toStringTag](): string
  • Returns the default string description of an object. Required to implement the Promise interface.

    Returns string

  • get content(): string
  • An alias for the css property. Use it with syntaxes that generate non-CSS output.

    This property will only work with synchronous plugins. If the processor contains any asynchronous plugins it will throw an error.

    PostCSS runners should always use LazyResult#then.

    Returns string

  • get css(): string
  • Processes input CSS through synchronous plugins, converts Root to a CSS string and returns Result#css.

    This property will only work with synchronous plugins. If the processor contains any asynchronous plugins it will throw an error.

    PostCSS runners should always use LazyResult#then.

    Returns string

  • Processes input CSS through synchronous plugins and returns Result#map.

    This property will only work with synchronous plugins. If the processor contains any asynchronous plugins it will throw an error.

    PostCSS runners should always use LazyResult#then.

    Returns SourceMap

  • Processes input CSS through synchronous plugins and returns Result#messages.

    This property will only work with synchronous plugins. If the processor contains any asynchronous plugins it will throw an error.

    PostCSS runners should always use LazyResult#then.

    Returns Message[]

  • Options from the Processor#process call.

    Returns ResultOptions

  • Returns a Processor instance, which will be used for CSS transformations.

    Returns Processor_

  • get root(): RootNode
  • Processes input CSS through synchronous plugins and returns Result#root.

    This property will only work with synchronous plugins. If the processor contains any asynchronous plugins it will throw an error.

    PostCSS runners should always use LazyResult#then.

    Returns RootNode

Methods

  • async(): Promise<Result_<RootNode>>
  • Run plugin in async way and return Result.

    Returns Promise<Result_<RootNode>>

    Result with output content.

  • Run plugin in sync way and return Result.

    Returns Result_<RootNode>

    Result with output content.

  • toString(): string
  • Alias for the LazyResult#css property.

    lazy + '' === lazy.css
    

    Returns string

    Output CSS.

  • Processes input CSS through synchronous plugins and calls Result#warnings.

    Returns Warning_[]

    Warnings from plugins.