Skip to content

Conversation

@nsaunders
Copy link
Owner

@nsaunders nsaunders commented May 13, 2023

Description

  • Nth type renamed to AnPlusB (inspired by csstree)
  • Even and Odd constructors dropped in favor of a single AnPlusB constructor
  • nth function replaced by the operators #+ and #-
  • even and odd functions just use AnPlusB constructor and are rendered as equivalent formulas (2n and 2n+1 respectively).

Design considerations

  1. nthChild (nth 2 1) is a bit repetitive and doesn't look much like the an+b format. Therefore it might be unclear at first what the parameters represent.
  2. Considering Selector API changes #1, I was going to rename the function to anplusb as I would have considered that to have stronger semantics than nth. But then I got the idea to add these operators instead.
  3. Similarly the Nth data type is less clear than AnPlusB.
  4. Removing the Even and Odd constructors was mostly just about simplifying things. But there is an incremental performance benefit also, in that 2n and 2n+1 add up to 6 characters in total, while even and odd add up to 7 characters. Thus, the rendered output will be slightly more compact.

Future plans

N/A

References

Code change checklist

  • Any new or updated functionality includes corresponding unit test coverage.
  • I have verified code formatting, run the unit tests, and checked for any changes in the examples.
  • I have added an entry to the Unreleased section of the CHANGELOG.

@nsaunders nsaunders merged commit 60f2f1a into master May 13, 2023
@nsaunders nsaunders added enhancement New feature or request breaking Non-backward-compatible API change labels May 13, 2023
@nsaunders nsaunders deleted the feature/anplusb-operators branch July 27, 2023 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Non-backward-compatible API change enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants