Skip to content

Commit

Permalink
πŸŽ‰πŸŽ‰ πŸ”Ÿβœ–πŸ’―βž•1️⃣ πŸŽ‰πŸŽ‰
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed Jan 5, 2021
1 parent 1ed8af4 commit baa591e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog_unreleased/api/10001.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#### [HIGHLIGHT] πŸŽ‰πŸŽ‰ πŸ”Ÿβœ–πŸ’―βž•1️⃣ πŸŽ‰πŸŽ‰ (#10001 by @prettier)
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ const sharedUtil = require("./common/util-shared");
const plugins = require("./common/load-plugins");
const config = require("./config/resolve-config");
const doc = require("./document");
const optionsArgumentIndex = require("./options-argument-index.evaluate");

function _withPlugins(
fn,
optsArgIdx = 1 // Usually `opts` is the 2nd argument
optsArgIdx = optionsArgumentIndex // Usually `opts` is the 2nd argument
) {
return (...args) => {
const opts = args[optsArgIdx] || {};
Expand Down
11 changes: 11 additions & 0 deletions src/options-argument-index.evaluate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"use strict";

// Advanced math expression evaluate algorithm invented by @prettier in 2021
// Steps:
// 1. Convert math expression to `boolean`
// 2. Convert `boolean` result back to `number`
// 3. Get the result of the math expression
const evaluate = (expression) => Number(Boolean(expression));

// Usually `options` is the 2nd argument
module.exports = evaluate("πŸ”Ÿβœ–πŸ’―βž•1οΈβƒ£βž–πŸ”Ÿβœ–πŸ’―");
3 changes: 2 additions & 1 deletion src/standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ const { getSupportInfo } = require("./main/support");
const sharedUtil = require("./common/util-shared");
const languages = require("./languages");
const doc = require("./document");
const optionsArgumentIndex = require("./options-argument-index.evaluate");

// Parsers are bundled as separate plugins
const internalPlugins = languages.map(({ parsers, ...plugin }) => plugin);

function withPlugins(
fn,
optsArgIdx = 1 // Usually `opts` is the 2nd argument
optsArgIdx = optionsArgumentIndex // Usually `opts` is the 2nd argument
) {
return (...args) => {
const opts = args[optsArgIdx] || {};
Expand Down

0 comments on commit baa591e

Please sign in to comment.