Skip to content

Latest commit

 

History

History
3901 lines (2768 loc) · 117 KB

File metadata and controls

3901 lines (2768 loc) · 117 KB

Roadmap

The focus of this package is to provide convenient functions and monads to write readable code (as close as possible to elementary English language). So there are no plans to support low-level interfaces for the v1.0 (like DataView or ArrayBuffer).

The primary features are the Maybe and Result monads, and as monads and functors require a unary function parameter, this package tries to close the gap between existing ECMAScript functions.

The general approach is the following:

  • Static unary functions and methods from JavaScript should be used as is, unless they return some odd values for edge cases (e.g. NaN, Infinity, -1). In such cases, a corresponding function is added, to return null (or undefined).

  • Unary instance methods should have a corresponding function that can be used as a callback. For example, for the String.prototype.split() method, there is a corresponding split() function. So the code like .then(v ⇒ v.split(';')) can be just .then(split(';')).

    At the moment, most of the functions have the same name as the method, but that may change later before v1.0.

  • Unary function or method with an optional argument may have a corresponding function (or two) with strict parameters.

    For example, new Date() has a corresponding now() function.

  • Built-in binary and ternary functions and methods may have one or more corresponding functions to create callbacks with partial application of the arguments.

Version 1.0

  • Must target ECMAScript 6.

    • Only versions starting from ECMAScript 2015 (ES6) are considered.

    • The version ES6 means that the feature is available in ES6, even if it was introduced earlier.

    • All versions after ES6 are written in their year-based format (e.g. ES2016).

  • May support newer versions of ECMAScript if they have wide browser and TypeScript support.

  • Legacy browsers support may be provided using @babel.

Version 2.0

Version 2.0 will be considered after v1.0 is released, if:

  • TypeScript adds support for nominal types, partial application, or other features that can improve compile-time strictness of the types.

JavaScript ECMA Perfective

Constructor

AggregateError()

ES2021

TBD

Properties

errors

ES2021

TBD

JavaScript ECMA Perfective

Constructor

Array()

ES6

Prohibited. Use array() as a callback.

Array(length)

ES6

Prohibited. Use replicated() to create an array of a certain length.

Array(…​items)

ES6

Prohibited. Use array() as a callback.

Properties

[@@species]

ES6

TBD

[@@unscopables]

ES2016

TBD

length

ES6

  • Use isEmpty()/isNotEmpty() predicates.

  • Use length() from @perfective/common/function to check length.

Methods

[@@iterator]()

ES2016

TBD

at()

ES2022

TBD

concat()

ES6

Use concat() to create a callback. Use conactenated() to concatenate arrays.

copyWithin()

ES6

Use copyWithin() to create a callback.

entries()

ES6

Use entries() as a callback.

every()

ES6

Use every() to create a callback.

fill()

ES6

Use fill() to create a callback.

filter()

ES6

Use filter() to create a callback.

find()

ES6

Use find() to create a callback.

findIndex()

ES6

Use findIndex() to create a callback.

findLast()

ES2023

TBD

findLastIndex()

ES2023

TBD

flat()

ES2019

TBD

flatMap()

ES2019

TBD

forEach()

ES6

Use forEach() to create a callback.

from()

ES6

  • Use elements() to create an array from Iterable and ArrayLike

  • Use copy() to copy an array.

fromAsync()

Draft

TBD

includes()

ES2016

  • Use includes()/includedIn() to create a callback.

indexOf()

ES6

Use indexOf() to create a callback.

isArray()

ES6

Use isArray()/isNotArray() as callbacks and shortcuts.

join()

ES6

Use join() to create a callback.

keys()

ES6

Use keys() as a callback.

lastIndexOf()

ES6

Use lastIndexOf() to create a callback.

map()

ES6

Use map() to create a callback.

of()

ES6

Use array() to create an array.

pop()

ES6

  • Use pop() as a mutating callback.

  • Use end() to return the last element.

push()

ES6

  • Use push()/pushInto() to create a callback.

  • Use append() as a callback to create a shallow copy.

reduce()

ES6

Use reduce()/reduceTo() to create a callback.

reduceRight()

ES6

Use reduceRight()/reduceRightTo() to create a callback.

reverse()

ES6

  • Use reverse() as a mutating callback.

  • Use reversed() to reverse a shallow copy.

shift()

ES6

  • Use shift() as a mutating callback.

  • Use head() to get the first element.

slice()

ES6

Use slice() to create a callback.

some()

ES6

Use some() to create a callback.

sort()

ES6

  • Use sort() to create a mutating callback.

  • Use sorted() to sort a shallow copy.

splice()

ES6

Use slice()/spliceWith() to create a callback.

toLocaleString()

ES6

TBD

toReversed()

ES2023

Use reversed() to reverse a shallow copy.

toSorted()

ES2023

Use sorted() to sort a shallow copy.

toSpliced()

ES2023

TBD

toString()

ES6

TBD

unshift()

ES6

  • Use unshift() to create a mutating callback.

  • Use prepend() to create a shallow copy callback.

values()

ES6

Use values() as a callback.

with()

ES2023

TBD

Not planned for the v1.0 as it is a low-level (binary data) functionality.

JavaScript ECMA Perfective

Constructor

ArrayBuffer()

ES6

N/A

Properties

[@@species]

ES6

N/A

byteLength

ES6

N/A

detached

Stage 3

N/A

maxByteLength

Stage 4

N/A

resizable

Stage 4

N/A

Methods

isView()

ES6

N/A

resize()

Stage 4

N/A

slice()

ES6

N/A

transfer()

Stage 3

N/A

transferToFixedLength()

Stage 3

N/A

JavaScript ECMA Perfective

Constructor

AsyncFunction()

ES2017

TBD

JavaScript ECMA Perfective

Methods

next()

ES2018

TBD

return()

ES2018

TBD

throw()

ES2018

TBD

JavaScript ECMA Perfective

Constructor

AsyncGeneratorFunction()

ES2018

TBD

JavaScript ECMA Perfective

Methods

[@@asyncIterator]()

ES2018

TBD

Not planned for the v1.0 as it is not part of the ES6 standard.

JavaScript ECMA Perfective

Methods

add()

ES2017

N/A

and()

ES2017

N/A

compareExchange()

ES2017

N/A

exchange()

ES2017

N/A

isLockFree()

ES2017

N/A

load()

ES2017

N/A

notify()

ES2017

N/A

or()

ES2017

N/A

store()

ES2017

N/A

sub()

ES2017

N/A

wait()

ES2017

N/A

waitAsync()

ESNext

N/A

wake()

ES2017-ES2018

N/A

xor()

ES2017

N/A

Not planned for the v1.0 as it is not part of the ES6 standard.

JavaScript ECMA Perfective

Constructor

BigInt()

ES2020

N/A

Methods

asIntN()

ES2020

N/A

asUintN()

ES2020

N/A

toLocaleString()

ES2020

N/A

toString()

ES2020

N/A

valueOf()

ES2020

N/A

Not planned for the v1.0 as it is a low-level (binary data) functionality.

JavaScript ECMA Perfective

Constructor

BigInt64Array()

ES2020

N/A

Not planned for the v1.0 as it is a low-level (binary data) functionality.

JavaScript ECMA Perfective

Constructor

BigUint64Array()

ES2020

N/A

JavaScript ECMA Perfective

Constructor

new Boolean()

ES6

Prohibited. Use ESLint the no-new-wrappers to enforce.

In conditional statements, new Boolean(false) evaluates to true, so using the Boolean object is strongly discouraged.

Boolean

ES6

Supported. Use the isTruthy()/isFalsy() predicates.

Methods

toString()

ES6

Use the String() function.

valueOf()

ES6

Not Supported. As the new Boolean() constructor is disallowed, there is no need in using the valueOf() method.

When a primitive value is expected, JavaScript invokes valueOf() automatically.

Not planned for the v1.0 as it is a low-level (binary data) functionality.

JavaScript ECMA Perfective

Constructor

DataView()

ES6

N/A

Properties

buffer

ES6

N/A

byteLength

ES6

N/A

byteOffset

ES6

N/A

Methods

getBigInt64()

ES2020

N/A

getBigUint64()

ES2020

N/A

getFloat32()

ES6

N/A

getFloat64()

ES6

N/A

getInt16()

ES6

N/A

getInt32()

ES6

N/A

getInt8()

ES6

N/A

getUint16()

ES6

N/A

getUint32()

ES6

N/A

getUint8()

ES6

N/A

setBigInt64()

ES2020

N/A

setBigUint64()

ES2020

N/A

setFloat32()

ES6

N/A

setFloat64()

ES6

N/A

setInt16()

ES6

N/A

setInt32()

ES6

N/A

setInt8()

ES6

N/A

setUint16()

ES6

N/A

setUint32()

ES6

N/A

setUint8()

ES6

N/A

The @perfective/common/date package covers the ES6 Date objects.

JavaScript ECMA Perfective

Constructor

new Date()

ES6

Discouraged. Instead, use the now() function to create the current Date object, as it relies on the Date.now function that can be mocked in the tests.

new Date(value)

ES6

Supported. Use the date() function to pass a timestamp. (Note: it returns null instead of "Invalid Date", if the timestamp is invalid).

new Date(dateString)

ES6

Supported. Use the date() function to pass a string. (Note: it returns null instead of "Invalid Date", if parsing fails).

new Date(dateObject)

ES6

Supported. Use the date() function to copy a Date. (Note: it returns null when given an "Invalid Date").

new Date(year, monthIndex, …​)

ES6

TBD

Date()

ES6

Discouraged. Use the date() function instead.

Methods

@@toPrimitive()

ES6

Discouraged. Use explicit conversions instead.

getDate()

ES6

TBD

getDay()

ES6

TBD

getFullYear()

ES6

TBD

getHours()

ES6

TBD

getMilliseconds()

ES6

TBD

getMinutes()

ES6

TBD

getMonth()

ES6

TBD

getSeconds()

ES6

TBD

getTime()

ES6

TBD

getTimezoneOffset()

ES6

TBD

getUTCDate()

ES6

TBD

getUTCDay()

ES6

TBD

getUTCFullYear()

ES6

TBD

getUTCHours()

ES6

TBD

getUTCMilliseconds()

ES6

TBD

getUTCMinutes()

ES6

TBD

getUTCMonth()

ES6

TBD

getUTCSeconds()

ES6

TBD

getYear()

ES6

Disallowed. The method is deprecated.

Date.now()

ES6

  • Use the now() function to create the current Date. now() uses Date.now(), so it can be mocked in tests.

  • Use the Date.now() when you need a timestamp.

Date.parse()

ES6

Discouraged. Date.parse() returns NaN if the value cannot be parsed. Use the timestamp() function instead, as it returns null if the input string cannot be parsed, so it can be composed using the maybe() monad.

setDate()

ES6

Prohibited. The method mutates the date.

setFullYear()

ES6

Prohibited. The method mutates the date.

setHours()

ES6

Prohibited. The method mutates the date.

setMilliseconds()

ES6

Prohibited. The method mutates the date.

setMinutes()

ES6

Prohibited. The method mutates the date.

setMonth()

ES6

Prohibited. The method mutates the date.

setSeconds()

ES6

Prohibited. The method mutates the date.

setTime()

ES6

Prohibited. The method mutates the date.

setUTCDate()

ES6

Prohibited. The method mutates the date.

setUTCFullYear()

ES6

Prohibited. The method mutates the date.

setUTCHours()

ES6

Prohibited. The method mutates the date.

setUTCMilliseconds()

ES6

Prohibited. The method mutates the date.

setUTCMinutes()

ES6

Prohibited. The method mutates the date.

setUTCMonth()

ES6

Prohibited. The method mutates the date.

setUTCSeconds()

ES6

Prohibited. The method mutates the date.

setYear()

ES6

Prohibited. The method is deprecated and mutates the date.

toDateString()

ES6

TBD

toISOString()

ES6

TBD

toJSON()

ES6

No custom support. Use JSON.encode() to JSON conversions.

toLocaleDateString()

ES6

TBD

toLocaleString()

ES6

TBD

toLocaleTimeString()

ES6

TBD

toString()

ES6

TBD

toTimeString()

ES6

TBD

toUTCString()

ES6

TBD (Alias: toGMTString()).

Date.UTC()

ES6

TBD

valueOf()

ES6

Discouraged. Use the timestamp() function to get the timestamp.

  • valueOf() returns NaN for invalid dates.

  • timestamp() returns null for invalid dates.

JavaScript ECMA Perfective

decodeURI()

ES6

TBD

JavaScript ECMA Perfective

decodeURIComponent()

ES6

TBD

JavaScript ECMA Perfective

encodeURI()

ES6

TBD

JavaScript ECMA Perfective

encodeURIComponent()

ES6

TBD

The @perfective/common/error package provides support for the Error Objects.

JavaScript ECMA Perfective

Constructor

Error()

ES6

Use error() to create a new Error.

Properties

cause

ES2022

TBD

columnNumber

None

Not supported as non-standard. Use stackTrace() to parse out Trace.column from the Error.stack.

fileName

None

Not supported as non-standard. Use stackTrace() to parse out Trace.filename from the Error.stack.

lineNumber

None

Not supported as non-standard. Use stackTrace() to parse out Trace.line from the Error.stack.

message

ES6

TBD

name

ES6

TBD

stack

None

  • Use stack() to return the Error.stack, if it is defined.

  • Use stackTrace() to return a parsed stack trace.

Methods

toString()

ES6

  • Use String() as a callback.

  • Use errorOutput() as a generic standardized output callback.

JavaScript ECMA Perfective

escape()

ES6

Prohibited as deprecated.

JavaScript ECMA Perfective

eval()

ES6

Prohibited as unsafe.

The @perfective/common/error package provides support for the Error Objects.

JavaScript ECMA Perfective

Constructor

EvalError()

ES6

Use evalError() to create an EvalError.

Not planned for the v1.0 as it is not part of the ES6 standard.

JavaScript ECMA Perfective

Constructor

FinalizationRegistry()

ES2021

N/A

Methods

register()

ES2021

N/A

unregister()

ES2021

N/A

Not planned for the v1.0 as it is a low-level (binary data) functionality.

JavaScript ECMA Perfective

Constructor

Float32Array()

ES6

N/A

Not planned for the v1.0 as it is a low-level (binary data) functionality.

JavaScript ECMA Perfective

Constructor

Float64Array()

ES6

N/A

JavaScript ECMA Perfective

Constructor

new Function()

ES6

Prohibited as unsafe.

Function()

ES6

Prohibited as unsafe.

Properties

arguments

Prohibited as deprecated and non-standard.

caller

Prohibited as deprecated and non-standard.

displayName

Prohibited as non-standard.

length

ES6

  • Length type and its functions.

  • isNullary(), isUnary(), isBinary(), and isTernary() predicates.

name

ES6

TODO #10

prototype

ES6

TODO #11

Methods

@@hasInstance

ES6

Supported via the instanceof operator.

apply()

ES6

TBD.

bind()

ES6

TBD.

call()

ES6

TBD.

toString()

ES6

Use the String() function.

JavaScript ECMA Perfective

Methods

next()

ES6

TBD

return()

ES6

TBD

throw()

ES6

TBD

JavaScript ECMA Perfective

Constructor

GeneratorFunction()

ES6

TBD

JavaScript ECMA Perfective

globalThis

ES2020

TBD

JavaScript ECMA Perfective

Infinity

ES6

Prohibited. Prefer Number.POSITIVE_INFINITY over Infinity (Use unicorn/prefer-number-properties ESLint rule to enforce).

Not planned for the v1.0 as it is a low-level (binary data) functionality.

JavaScript ECMA Perfective

Constructor

Int16Array()

ES6

N/A

Not planned for the v1.0 as it is a low-level (binary data) functionality.

JavaScript ECMA Perfective

Constructor

Int32Array()

ES6

N/A

Not planned for the v1.0 as it is a low-level (binary data) functionality.

JavaScript ECMA Perfective

Constructor

Int8Array()

ES6

N/A

JavaScript ECMA Perfective

Constructor

InternalError()

None

Not supported as non-standard.

JavaScript ECMA Perfective

Methods

getCanonicalLocales()

ES2016

TBD

supportedValuesOf()

Draft

TBD

JavaScript ECMA Perfective

Constructor

Collator()

ES2015

TBD

Methods

compare()

ES2015

TBD

resolvedOptions()

ES2015

TBD

supportedLocalesOf()

ES2015

TBD

JavaScript ECMA Perfective

Constructor

ListFormat()

ES2021

TBD

Methods

format()

ES2021

TBD

formatToParts()

ES2021

TBD

resolvedOptions()

ES2021

TBD

supportedLocalesOf()

ES2021

TBD

JavaScript ECMA Perfective

Constructor

PluralRules()

ES2018

TBD

Methods

resolvedOptions()

ES2018

TBD

select()

ES2018

TBD

selectRange()

Draft

TBD

supportedLocalesOf()

ES2018

TBD

JavaScript ECMA Perfective

Constructor

Segmenter()

ES2022

TBD

Methods

resolvedOptions()

ES2022

TBD

segment()

ES2022

TBD

supportedLocalesOf()

ES2022

TBD

JavaScript ECMA Perfective

isFinite()

ES6

Prohibited. Use Number.isFinite instead. Use unicorn/prefer-number-properties ESLint rule to enforce.

JavaScript ECMA Perfective

iNaN()

ES6

Prohibited. Use Number.isNaN instead. Use unicorn/prefer-number-properties ESLint rule to enforce.

JavaScript ECMA Perfective

Methods

[@@iterator]()

ES6

TBD

JavaScript ECMA Perfective

Methods

parse()

ES6

TBD

stringify()

ES6

TBD

JavaScript ECMA Perfective

Constructor

Map()

ES6

TBD

Properties

[@@species]

ES6

TBD

size

ES6

TBD

Methods

[@@iterator]()

ES6

TBD

clear()

ES6

TBD

delete()

ES6

TBD

entries()

ES6

TBD

forEach()

ES6

TBD

get()

ES6

TBD

groupBy()

Stage 2

TBD

has()

ES6

TBD

keys()

ES6

TBD

set()

ES6

TBD

values()

ES6

TBD

The @perfective/common/number package covers the ES6 Math object.

JavaScript ECMA Perfective

Properties

E

ES6

Use directly

LN10

ES6

Use directly

LN2

ES6

Use directly

LOG10E

ES6

Use directly

LOG2E

ES6

Use directly

PI

ES6

Use directly

SQRT1_2

ES6

Use directly

SQRT2

ES6

Use directly

Methods

abs()

ES6

Use absolute() to assert correct input and avoid NaN output.

acos()

ES6

Use arccos() to assert correct input and avoid NaN output.

acosh()

ES6

Use arccosh() to assert correct input and avoid NaN output.

asin()

ES6

Use arcsin() to assert correct input and avoid NaN output.

asinh()

ES6

Use arcsinh() to assert correct input and avoid NaN output.

atan()

ES6

Use arctan() to assert correct input and avoid NaN output.

atan2()

ES6

Use arctan2() to assert correct input and avoid NaN output.

atanh()

ES6

Use arctanh() to assert correct input and avoid NaN output.

cbrt()

ES6

Use cubeRoot() to assert correct input and avoid NaN output.

ceil()

ES6

Use roundedUp() to assert correct input and avoid NaN output.

clz32()

ES6

N/A as a low-level (binary data) function.

cos()

ES6

Use cos() to assert correct input and avoid NaN output.

cosh()

ES6

Use arccosh() to assert correct input and avoid NaN output.

exp()

ES6

Use exp() to assert correct input and avoid NaN output.

expm1()

ES6

Use expm1() to assert correct input and avoid NaN output.

floor()

ES6

Use roundedDown() to assert correct input and avoid NaN output.

fround()

ES6

Use roundedToFloat32() to assert correct input and avoid NaN output.

hypot()

ES6

Use l2norm() to assert correct input and avoid NaN output.

imul()

ES6

N/A as a low-level (binary data) function.

log()

ES6

Use log() to assert correct input and avoid NaN output.

log10()

ES6

Use log10() to assert correct input and avoid NaN output.

log1p()

ES6

Use log1p() to assert correct input and avoid NaN output.

log2()

ES6

Use log2() to assert correct input and avoid NaN output.

max()

ES6

Prefer maximum() to exclude NaN.

min()

ES6

Prefer minimum() to exclude NaN.

pow()

ES6

Use power() to assert correct input and avoid NaN output. power() supports curried and tuple inputs. Use powerOf(exponent) for curried input of the second argument.

random()

ES6

TODO #24

round()

ES6

Use rounded() to assert correct input and avoid NaN output.

sign()

ES6

Use sign() to assert correct input and avoid NaN output.

sin()

ES6

Use sin() to assert correct input and avoid NaN output.

sinh()

ES6

Use sinh() to assert correct input and avoid NaN output.

sqrt()

ES6

Use squareRoot() to assert correct input and avoid NaN output.

tan()

ES6

Use tan() to assert correct input and avoid NaN output.

tanh()

ES6

Use tanh() to assert correct input and avoid NaN output.

trunc()

ES6

Use truncated() to assert correct input and avoid NaN output.

JavaScript ECMA Perfective

NaN

ES6

Discouraged. Return null instead of NaN for "not a number". Use Number.isNaN() to check for NaN.

JavaScript ECMA Perfective

Constructor

new Number()

ES6

Prohibited. Use the no-new-wrappers ESLint rule to enforce.

Number()

ES6

Discouraged. Use explicit conversions (e.g. decimal()).

Properties

EPSILON

ES6

Use directly

MAX_SAFE_INTEGER

ES6

Use directly

MAX_VALUE

ES6

Use directly

MIN_SAFE_INTEGER

ES6

Use directly

MIN_VALUE

ES6

Use directly

NaN

ES6

Discouraged

  • Use isNumber()/isNotNumber() as a type guard.

  • Return null instead of NaN or throw an error in functions.

NEGATIVE_INFINITY

ES6

Use directly

POSITIVE_INFINITY

ES6

Use directly

Methods

isFinite()

ES6

Prefer isFinite() as a type guard and assertIsFinite() for assertions.

isInteger()

ES6

Prefer isInteger() as a type guard.

isNaN()

ES6

Prefer isNumber()/isNotNumber() as a type guard. See TODO #19.

isSafeInteger()

ES6

Prefer isSafeInteger() as a type guard.

parseFloat()

ES6

Prefer decimal() as it returns null instead of NaN on failure.

parseInt()

ES6

Prefer decimal()/binary()/octal()/hexadecimal() as they return null instead of NaN on failure.

toExponential()

ES6

Use exponential() to create a callback.

toFixed()

ES6

Use fixed() to create a callback.

toLocaleString()

ES6

TBD

toPrecision()

ES6

Use precision() to create a callback.

toString()

ES6

Prefer decimal()/binary()/octal()/hexadecimal() for better readability.

valueOf()

ES6

TBD

The @perfective/common/object package covers the ECMAScript Object objects.

JavaScript ECMA Perfective

Constructor

Object()

ES6

Disallowed. Use the ESLint no-new-object rule to enforce.

Properties

constructor

ES6

TODO #17

__proto__

ES6

Deprecated

Methods

__defineGetter__()

Legacy

Deprecated

__defineSetter__()

Legacy

Deprecated

__lookupGetter__()

Legacy

Deprecated

__lookupSetter__()

Legacy

Deprecated

assign()

ES6

TODO #12

create()

ES6

Use directly

defineProperties()

ES6

Use directly

defineProperty()

ES6

Use directly

entries()

ES2017

Use directly

freeze()

ES6

Use directly

fromEntries()

ES2019

  • Use Object.fromEntries() directly for ES2019+

  • Use recordFromEntries for versions before ES2019.

getOwnPropertyDescriptor()

ES6

Use directly

getOwnPropertyDescriptors()

ES2017

Use directly

getOwnPropertyNames()

ES6

Use directly

getOwnPropertySymbols()

ES6

Use directly

getPrototypeOf()

ES6

Use directly

groupBy()

Stage 2

TBD

hasOwn()

ES2022

TODO #13

hasOwnProperty()

ES6

TODO #13

is()

ES6

TODO #14

isExtensible()

ES6

Use directly

isFrozen()

ES6

Use directly

isPrototypeOf()

ES6

TODO #15

isSealed()

ES6

Use directly

keys()

ES6

Use directly

preventExtensions()

ES6

Use directly

propertyIsEnumerable()

ES6

TODO #16

seal()

ES6

Use directly

setPrototypeOf()

ES6

Prohibited

toLocaleString()

ES6

TBD

toString()

ES6

Use String() as a callback.

valueOf()

ES6

TBD

values()

ES2018

Use directly

JavaScript ECMA Perfective

parseFloat()

ES6

Prohibited. Use decimal() from @perfective/common/number instead.

JavaScript ECMA Perfective

parseInt()

ES6

Prohibited. Use decimal(), binary(), octal(), and hexadecimal() from @perfective/common/number instead.

Use Number.parseInt(), if a custom radix is required. Use unicorn/prefer-number-properties ESLint rule to enforce.

The @perfective/common/promise package provides support for the Promise Jobs.

JavaScript ECMA Perfective

Constructor

Promise()

ES6

  • Use promise() to create a Promise.

  • Use settlement() to promisify error-first callback functions.

  • Use Executor to define Promise constructor arguments.

Properties

[@@species]

ES6

No custom support.

Methods

all()

ES6

No custom support.

allSettled()

ES2020

No custom support.

any()

ES2021

No custom support.

catch()

ES6

Use OnRejected type to define callbacks.

finally()

ES2018

No custom support.

race()

ES6

No custom support.

reject()

ES6

Use rejected() to create a rejected Promise.

resolve()

ES6

Use fulfilled() to create a resolved Promise.

then()

ES6

Use OnFulfilled and OnRejected types to define callbacks.

The @perfective/common/error package provides support for the Error Objects.

JavaScript ECMA Perfective

Constructor

RangeError()

ES6

Use rangeError() to create a RangeError.

The @perfective/common/error package provides support for the Error Objects.

JavaScript ECMA Perfective

Constructor

ReferenceError()

ES6

Use referenceError() to create a ReferenceError.

JavaScript ECMA Perfective

Constructor

RegExp()

ES6

TBD

Properties

[@@species]

ES6

TBD

dotAll

ES2018

TBD

flags

ES6

TBD

global

ES6

TBD

hasIndices

ES2022

TBD

ignoreCase

ES6

TBD

input ($_)

Legacy

Prohibited as deprecated.

RegExp: lastIndex

ES6

TBD

lastMatch ($&)

Legacy

Prohibited as deprecated.

lastParen ($+)

Legacy

Prohibited as deprecated.

leftContext ($)

Legacy

Prohibited as deprecated.

multiline

ES6

TBD

RegExp.$1, …, RegExp.$9

Legacy

Prohibited as deprecated.

RegExp.rightContext ($')

Legacy

Prohibited as deprecated.

source

ES6

TBD

sticky

ES6

TBD

unicode

ES6

TBD

unicodeSets

ES2024

TBD

Methods

@@match()

ES6

TBD

@@matchAll()

ES2020

TBD

@@replace()

ES6

TBD

@@search()

ES6

TBD

@@split()

ES6

TBD

compile()

ES6

Deprecated

exec()

ES6

TBD

test()

ES6

TBD

toString()

ES6

TBD

JavaScript ECMA Perfective

Constructor

Set()

ES6

TBD

Properties

[@@species]

ES6

TBD

size

ES6

TBD

Methods

[@@iterator]()

ES6

TBD

add()

ES6

TBD

clear()

ES6

TBD

delete()

ES6

TBD

entries()

ES6

TBD

forEach()

ES6

TBD

has()

ES6

TBD

keys()

ES6

TBD

values()

ES6

TBD

Not planned for the v1.0 as it is a low-level (binary data) functionality.

JavaScript ECMA Perfective

Constructor

SharedArrayBuffer()

ES2017

N/A

Properties

[@@species]()

ES2017

N/A

byteLength

ES2017

N/A

growable

Stage 4

N/A

maxByteLength

Stage 4

N/A

Methods

grow()

Stage 4

N/A

slice()

ES2017

N/A

JavaScript ECMA Perfective

Constructor

new String()

ES6

Prohibited. Use the ESLint no-new-wrappers rule to enforce.

String()

ES6

Use to cast a value to string.

Properties

length

ES6

Use the Length interface and the length() function from the @perfective/common/function.

Methods

[@@iterator]()

ES6

No custom support

anchor()

ES6

Deprecated

at()

ES2022

TBD

big()

ES6

Deprecated

blink()

ES6

Deprecated

bold()

ES6

Deprecated

charAt()

ES6

Use charAt() to create a callback.

charCodeAt()

ES6

Use charCodeAt() to create a callback.

codePointAt()

ES6

Use codePointAt() to create a callback.

concat()

ES6

Use concat() and concatTo() to create a callback.

endsWith()

ES6

Use endsWith() to create a callback.

fixed()

ES6

Deprecated

fontcolor()

ES6

Deprecated

fontsize()

ES6

Deprecated

fromCharCode()

ES6

Use String.fromCharCode() directly.

fromCodePoint()

ES6

Use String.fromCodePoint() directly.

includes()

ES6

Use includes() to create a callback.

indexOf()

ES6

Use indexOf() to create a callback.

isWellFormed()

ESNext

TBD

italics()

ES6

Deprecated

lastIndexOf()

ES6

Use lastIndexOf() to create a callback.

link()

ES6

Deprecated

localeCompare()

ES6

TBD

match()

ES6

TBD

matchAll()

ES2020

TBD

normalize()

ES6

Use normalize() to create a callback.

padEnd()

ES

Use padEnd() to create a callback.

padStart()

ES

Use padStart() to create a callback.

raw()

ES6

Use String.raw() directly.

repeat()

ES6

Use repeat() to create a callback.

replace()

ES6

Use replace() and replaceWith() to create a callback.

replaceAll()

ES2021

Use replaceAll() to create a callback.

search()

ES6

Use search() to create a callback.

slice()

ES6

Use slice() to create a callback.

small()

ES6

Deprecated

split()

ES6

Use split() to create a callback.

startsWith()

ES6

Use startsWith() to create a callback.

strike()

ES6

Deprecated

sub()

ES6

Deprecated

substr()

ES6

Deprecated

substring()

ES6

Prefer String#slice() over String#substring(). Use the unicorn/prefer-string-slice ESLint rule to enforce.

sup()

ES6

Deprecated

toLocaleLowerCase()

ES6

TBD

toLocaleUpperCase()

ES6

TBD

toLowerCase()

ES6

Use lowerCase() as a callback.

toString()

ES6

Use String() as a callback.

toUpperCase()

ES6

Use upperCase() as a callback.

toWellFormed()

ESNext

TBD

trim()

ES6

Use trim() as a callback.

trimEnd()

ES2019

TBD

trimStart()

ES2019

TBD

valueOf()

ES6

TBD

JavaScript ECMA Perfective

Constructor

Symbol()

ES6

TBD

Properties

asyncIterator

ES2018

TBD

description

ES6

TBD

hasInstance

ES6

TBD

isConcatSpreadable

ES6

TBD

iterator

ES6

TBD

match

ES6

TBD

matchAll

ES2020

TBD

replace

ES6

TBD

search

ES6

TBD

species

ES6

TBD

split

ES6

TBD

toPrimitive

ES6

TBD

toStringTag

ES6

TBD

unscopables

ES6

TBD

Methods

[@@toPrimitive]()

ES6

TBD

for()

ES6

TBD

keyFor()

ES6

TBD

toString()

ES6

TBD

valueOf()

ES6

TBD

The @perfective/common/error package provides support for the Error Objects.

JavaScript ECMA Perfective

Constructor

SyntaxError()

ES6

Use syntaxError() to create a SyntaxError.

Not planned for the v1.0 as it is a low-level (binary data) functionality.

JavaScript ECMA Perfective

Properties

[@@species]

ES6

N/A

buffer

ES6

N/A

byteLength

ES6

N/A

byteOffset

ES6

N/A

BYTES_PER_ELEMENT

ES6

N/A

length

ES6

N/A

Methods

[@@iterator]()

ES6

N/A

at()

ES2022

N/A

copyWithin()

ES6

N/A

entries()

ES6

N/A

every()

ES6

N/A

fill()

ES6

N/A

filter()

ES6

N/A

find()

ES6

N/A

findIndex()

ES6

N/A

findLastIndex()

ES2023

N/A

forEach()

ES6

N/A

from()

ES6

N/A

includes()

ES2016

N/A

indexOf()

ES6

N/A

join()

ES6

N/A

keys()

ES6

N/A

lastIndexOf()

ES6

N/A

map()

ES6

N/A

of()

ES6

N/A

reduce()

ES6

N/A

reduceRight()

ES6

N/A

reverse()

ES6

N/A

set()

ES6

N/A

slice()

ES6

N/A

some()

ES6

N/A

sort()

ES6

N/A

subarray()

ES6

N/A

toLocaleString()

ES6

N/A

toReversed()

ES2023

N/A

toSorted()

ES2023

N/A

toString()

ES6

N/A

values()

ES6

N/A

with()

ES2023

N/A

The @perfective/common/error package provides support for the Error Objects.

JavaScript ECMA Perfective

Constructor

TypeError()

ES6

Use TypeError() to create a TypeError.

Not planned for the v1.0 as it is a low-level (binary data) functionality.

JavaScript ECMA Perfective

Constructor

Uint16Array()

ES6

N/A

Not planned for the v1.0 as it is a low-level (binary data) functionality.

JavaScript ECMA Perfective

Constructor

Uint32Array()

ES6

N/A

Not planned for the v1.0 as it is a low-level (binary data) functionality.

JavaScript ECMA Perfective

Constructor

Uint8Array()

ES6

N/A

Not planned for the v1.0 as it is a low-level (binary data) functionality.

JavaScript ECMA Perfective

Constructor

Uint8ClampedArray()

ES6

N/A

@perfective/common provides functions to work with undefined.

JavaScript ECMA Perfective

undefined

ES6

  • isDefined()/isUndefined() to check for undefined values. or isPresent()/isAbsent() to check for undefined | null values.

  • Use Maybe from @perfective/common/maybe to avoid undefined.

JavaScript ECMA Perfective

unescape()

ES6

Prohibited as deprecated.

JavaScript ECMA Perfective

Constructor

URIError()

ES6

TBD

JavaScript ECMA Perfective

Constructor

WeakMap()

ES6

TBD

Methods

delete()

ES6

TBD

get()

ES6

TBD

has()

ES6

TBD

set()

ES6

TBD

JavaScript ECMA Perfective

Constructor

WeakRef()

ES2021

TBD

Methods

deref()

ES2021

TBD

JavaScript ECMA Perfective

Constructor

WeakSet()

ES6

TBD

Methods

add()

ES6

TBD

delete()

ES6

TBD

has()

ES6

TBD

Addition (+)

ES6

TODO #33

Addition assignment (+=)

ES6

Discouraged as it mutates the value (TODO #33)

Assignment (=)

ES6

Use directly

async function expression

ES2017

Use directly

async function* expression

ES2018

Use directly

await

ES2017

Discouraged. Prefer Promise chaining.

Bitwise AND (&)

ES6

Discouraged as a bitwise operator.

Use Bitmasks from @perfective/common/number for bitmask manipulations.

Bitwise AND assignment (&=)

ES6

Discouraged as a bitwise operator and as it mutates the value.

Bitwise NOT (~)

ES6

Discouraged as a bitwise operator.

Use Bitmasks from @perfective/common/number for bitmask manipulations.

Bitwise OR (|)

ES6

Discouraged as a bitwise operator.

Use Bitmasks from @perfective/common/number for bitmask manipulations.

Bitwise OR assignment (|=)

ES6

Discouraged as a bitwise operator and as it mutates the value.

Bitwise XOR (^)

ES6

Discouraged as a bitwise operator.

Use Bitmasks from @perfective/common/number for bitmask manipulations.

Bitwise XOR assignment (^=)

ES6

Discouraged as a bitwise operator and as it mutates the value.

class expression

ES6

Use directly

Comma operator (,)

ES6

Use directly

Conditional (ternary) operator

ES6

  • Avoid in trivial functions; prefer:

if (isX) {
    return a;
}
return b;
  • Use directly for trivial property assignments:

{
    a: isX ? a : b,
}
  • Use match() from @perfective/common/match for nested cases.

Decrement (--)

ES6

Discouraged as it mutates the value (TODO #33)

delete operator

ES6

Discouraged as it mutates the value.

Destructuring assignment

ES6

Use directly

Destructuring binding patterns

ES6

Use directly

Division (/)

ES6

TODO #33

Division assignment (/=)

ES6

Discouraged as it mutates the value (TODO #33).

Equality (==)

ES6

Disallowed. Use the ESLint eqeqeq rule to enforce.

The loose equality has obscure behavior: '0' == false and [] == false, but null != false, undefined != false, and {} != false.

Always use strict equality. When you need to coerce multiple types with logic that does not match isTruthy()/isFalsy(), write an explicit Predicate.

Exponentiation (**)

ES2016

TODO #20, TODO #33

Exponentiation assignment (**=)

ES2016

Discouraged as it mutates the value (TODO #33)

Function expression

ES6

Use directly

function* expression

ES6

Use directly

Greater than (>)

ES6

Use isGreaterThan() from @perfective/common/number to create a callback.

Greater than or equal (>=)

ES6

Use isGreaterThanOrEqualTo() from @perfective/common/number to create a callback.

Grouping operator (())

ES6

Use directly

import.meta

ES2020

Use directly

import()

ES2020

Use directly

in operator

ES6

TBD

Increment (++)

ES6

TODO #33

Inequality (!=)

ES6

Disallowed. Prefer strict inequality !==.

Use the ESLint eqeqeq rule to enforce.

instanceof

ES6

  • Instance, isInstanceOf(), isNotInstanceOf() from @perfective/common to create a callback.

Left shift (<<)

ES6

Discouraged as a bitwise operator.

Left shift assignment (<⇐)

ES6

Discouraged as a bitwise operator and as it mutates the value.

Less than (<)

ES6

Use isLessThan() from @perfective/common/number to create a callback.

Less than or equal ()

ES6

Use isLessThanOrEqualTo() from @perfective/common/number to create a callback.

Logical AND (&&)

ES6

Allowed. Use all()/neither() for lazy evaluation and callbacks.

Logical AND assignment (&&=)

ES6

Discouraged as it mutates the value.

Logical NOT (!)

ES6

Allowed. Use not() for lazy evaluation and callbacks.

Double NOT (!!)

ES6

Disallowed. Use the isTruthy() /isFalsy() predicates.

Logical OR (||)

ES6

Allowed. Use either() for lazy evaluation and callbacks.

Logical OR assignment (||=)

ES6

Discouraged as it mutates the value.

Multiplication (*)

ES6

TODO #33

Multiplication assignment (*=)

ES6

Discouraged as it mutates the value (see TODO #33).

new operator

ES6

Use directly.

new.target

ES6

Use directly.

null

ES6

Use directly.

Nullish coalescing assignment (??=)

ES2020

Discouraged as it mutates the value.

Nullish coalescing operator (??)

ES2020

Discouraged. Prefer Maybe chaining:

maybe(x).or(y)

Object initializer

ES6

Use directly.

Operator precedence

ES6

Use directly.

Optional chaining (?.)

ES2020

Discouraged. Prefer Maybe chaining:

maybe(x).pick('y')

Property accessors

ES6

Use directly.

Use property() from @perfective/common/object to create a callback.

Remainder (%)

ES6

TODO #33

Remainder assignment (%=)

ES6

Discouraged as it mutates the value (TODO #33)

Right shift (>>)

ES6

Discouraged as a bitwise operator.

Right shift assignment (>>=)

ES6

Discouraged as a bitwise operator and as it mutates the value.

Spread syntax

ES6

Use directly

Strict equality (===)

ES6

Allowed. Use is() for lazy evaluation and callbacks.

Strict inequality (!==)

ES6

Allowed. Use isNot() for lazy evaluation and callbacks.

Subtraction (-)

ES6

TODO #33

Subtraction assignment (-=)

ES6

Discouraged as it mutates the value (TODO #33)

super

ES6

Use directly

this

ES6

Use directly

typeof

ES6

Allowed.

Use isTypeOf()/isNotTypeOf() from @perfective/common to create a callback.

Unary negation (-)

ES6

Allowed.

Use negative() from @perfective/common/number as a callback.

Unary plus (+)

ES6

Disallowed.

Use decimal() from @perfective/common/number for explicit conversion.

Unsigned right shift (>>>)

ES6

Discouraged as a bitwise operator.

Unsigned right shift assignment (>>>=)

ES6

Discouraged as a bitwise operator and as it mutates the value.

void operator

ES6

Discouraged.

Use voidable() from @perfective/common for custom handling.

yield

ES6

Use directly

yield*

ES6

Use directly

References