Skip to content

(fun) - JavaScript

function definitions

clojure
(fun name? args? kind?)

Where:

  1. name: function name (providing a name excludes arrow functions) *
  2. args: function parameters *
  3. kind: function modifier to match *

Matching:

  1. declarations, e.g. function x() {}
  2. arrow functions, e.g. () => {}
  3. expressions, e.g. (function() {})
  4. generators, e.g. function* x() {}

Examples

Audit async functions before changing error handling behavior.

clojure
(fun _ _ (is async))

Selects in lines { 1, 2 } but not in { 3, 4 }:

typescript
async function loadUser() {}
const refresh = async () => {}
function loadUserSync() {}
function* ids() {}

Find APIs that already accept an AbortSignal so they can be wired to cancellation.

clojure
(fun _ (arg _ (id signal)))

Selects in lines { 1, 2 } but not in { 3 }:

typescript
function request(url, signal) {}
const withSignal = (signal, url) => {}
function withoutSignal(url) {}

Locate generator utilities before replacing them with async iterators.

clojure
(fun _ _ (is generator))

Selects in lines { 1, 2 } but not in { 3 }:

typescript
function* ids() { yield 1 }
const makeIds = function* () { yield 2 }
async function fetchIds() {}

Arguments

name

args

kind

Does NOT support: RefinementReplacement

Copyright © 2022-present Semantic Works, Inc.