e32fd3dd30d965b313639c28ee973c3d53cea79f265617ad87f6c7cf15c3a69bcb326a98248f1e509a8249c435224fe524565cf1903c508b9c35ba00a05792 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  1. import {LegacyPluginThis} from './plugin_this';
  2. /**
  3. * A synchronous callback that implements a custom Sass function. This can be
  4. * passed to {@link LegacySharedOptions.functions} for either {@link render} or
  5. * {@link renderSync}.
  6. *
  7. * If this throws an error, Sass will treat that as the function failing with
  8. * that error message.
  9. *
  10. * ```js
  11. * const result = sass.renderSync({
  12. * file: 'style.scss',
  13. * functions: {
  14. * "sum($arg1, $arg2)": (arg1, arg2) => {
  15. * if (!(arg1 instanceof sass.types.Number)) {
  16. * throw new Error("$arg1: Expected a number");
  17. * } else if (!(arg2 instanceof sass.types.Number)) {
  18. * throw new Error("$arg2: Expected a number");
  19. * }
  20. * return new sass.types.Number(arg1.getValue() + arg2.getValue());
  21. * }
  22. * }
  23. * });
  24. * ```
  25. *
  26. * @param args - One argument for each argument that's declared in the signature
  27. * that's passed to {@link LegacySharedOptions.functions}. If the signature
  28. * [takes arbitrary
  29. * arguments](https://sass-lang.com/documentation/at-rules/function#taking-arbitrary-arguments),
  30. * they're passed as a single argument list in the last argument.
  31. *
  32. * @category Legacy
  33. * @deprecated This only works with the legacy {@link render} and {@link
  34. * renderSync} APIs. Use {@link CustomFunction} with {@link compile}, {@link
  35. * compileString}, {@link compileAsync}, and {@link compileStringAsync} instead.
  36. */
  37. export type LegacySyncFunction = (
  38. this: LegacyPluginThis,
  39. ...args: LegacyValue[]
  40. ) => LegacyValue;
  41. /**
  42. * An asynchronous callback that implements a custom Sass function. This can be
  43. * passed to {@link LegacySharedOptions.functions}, but only for {@link render}.
  44. *
  45. * An asynchronous function must return `undefined`. Its final argument will
  46. * always be a callback, which it should call with the result of the function
  47. * once it's done running.
  48. *
  49. * If this throws an error, Sass will treat that as the function failing with
  50. * that error message.
  51. *
  52. * ```js
  53. * sass.render({
  54. * file: 'style.scss',
  55. * functions: {
  56. * "sum($arg1, $arg2)": (arg1, arg2, done) => {
  57. * if (!(arg1 instanceof sass.types.Number)) {
  58. * throw new Error("$arg1: Expected a number");
  59. * } else if (!(arg2 instanceof sass.types.Number)) {
  60. * throw new Error("$arg2: Expected a number");
  61. * }
  62. * done(new sass.types.Number(arg1.getValue() + arg2.getValue()));
  63. * }
  64. * }
  65. * }, (result, error) => {
  66. * // ...
  67. * });
  68. * ```
  69. *
  70. * This is passed one argument for each argument that's declared in the
  71. * signature that's passed to {@link LegacySharedOptions.functions}. If the
  72. * signature [takes arbitrary
  73. * arguments](https://sass-lang.com/documentation/at-rules/function#taking-arbitrary-arguments),
  74. * they're passed as a single argument list in the last argument before the
  75. * callback.
  76. *
  77. * @category Legacy
  78. * @deprecated This only works with the legacy {@link render} and {@link
  79. * renderSync} APIs. Use {@link CustomFunction} with {@link compile}, {@link
  80. * compileString}, {@link compileAsync}, and {@link compileStringAsync} instead.
  81. */
  82. export type LegacyAsyncFunction =
  83. | ((this: LegacyPluginThis, done: (result: LegacyValue) => void) => void)
  84. | ((
  85. this: LegacyPluginThis,
  86. arg1: LegacyValue,
  87. done: LegacyAsyncFunctionDone
  88. ) => void)
  89. | ((
  90. this: LegacyPluginThis,
  91. arg1: LegacyValue,
  92. arg2: LegacyValue,
  93. done: LegacyAsyncFunctionDone
  94. ) => void)
  95. | ((
  96. this: LegacyPluginThis,
  97. arg1: LegacyValue,
  98. arg2: LegacyValue,
  99. arg3: LegacyValue,
  100. done: LegacyAsyncFunctionDone
  101. ) => void)
  102. | ((
  103. this: LegacyPluginThis,
  104. arg1: LegacyValue,
  105. arg2: LegacyValue,
  106. arg3: LegacyValue,
  107. arg4: LegacyValue,
  108. done: LegacyAsyncFunctionDone
  109. ) => void)
  110. | ((
  111. this: LegacyPluginThis,
  112. arg1: LegacyValue,
  113. arg2: LegacyValue,
  114. arg3: LegacyValue,
  115. arg4: LegacyValue,
  116. arg5: LegacyValue,
  117. done: LegacyAsyncFunctionDone
  118. ) => void)
  119. | ((
  120. this: LegacyPluginThis,
  121. arg1: LegacyValue,
  122. arg2: LegacyValue,
  123. arg3: LegacyValue,
  124. arg4: LegacyValue,
  125. arg5: LegacyValue,
  126. arg6: LegacyValue,
  127. done: LegacyAsyncFunctionDone
  128. ) => void)
  129. | ((
  130. this: LegacyPluginThis,
  131. ...args: [...LegacyValue[], LegacyAsyncFunctionDone]
  132. ) => void);
  133. /**
  134. * The function called by a {@link LegacyAsyncFunction} to indicate that it's
  135. * finished.
  136. *
  137. * @param result - If this is a {@link LegacyValue}, that indicates that the
  138. * function call completed successfully. If it's a {@link types.Error}, that
  139. * indicates that the function call failed.
  140. *
  141. * @category Legacy
  142. * @deprecated This only works with the legacy {@link render} and {@link
  143. * renderSync} APIs. Use {@link CustomFunction} with {@link compile}, {@link
  144. * compileString}, {@link compileAsync}, and {@link compileStringAsync} instead.
  145. */
  146. export type LegacyAsyncFunctionDone = (
  147. result: LegacyValue | types.Error
  148. ) => void;
  149. /**
  150. * A callback that implements a custom Sass function. For {@link renderSync},
  151. * this must be a {@link LegacySyncFunction} which returns its result directly;
  152. * for {@link render}, it may be either a {@link LegacySyncFunction} or a {@link
  153. * LegacyAsyncFunction} which calls a callback with its result.
  154. *
  155. * See {@link LegacySharedOptions.functions} for more details.
  156. *
  157. * @category Legacy
  158. * @deprecated This only works with the legacy {@link render} and {@link
  159. * renderSync} APIs. Use {@link CustomFunction} with {@link compile}, {@link
  160. * compileString}, {@link compileAsync}, and {@link compileStringAsync} instead.
  161. */
  162. export type LegacyFunction<sync extends 'sync' | 'async'> = sync extends 'async'
  163. ? LegacySyncFunction | LegacyAsyncFunction
  164. : LegacySyncFunction;
  165. /**
  166. * A type representing all the possible values that may be passed to or returned
  167. * from a {@link LegacyFunction}.
  168. *
  169. * @category Legacy
  170. * @deprecated This only works with the legacy {@link render} and {@link
  171. * renderSync} APIs. Use {@link Value} with {@link compile}, {@link
  172. * compileString}, {@link compileAsync}, and {@link compileStringAsync} instead.
  173. */
  174. export type LegacyValue =
  175. | types.Null
  176. | types.Number
  177. | types.String
  178. | types.Boolean
  179. | types.Color
  180. | types.List
  181. | types.Map;
  182. /**
  183. * A shorthand for `sass.types.Boolean.TRUE`.
  184. *
  185. * @category Legacy
  186. * @deprecated This only works with the legacy {@link render} and {@link
  187. * renderSync} APIs. Use {@link sassTrue} with {@link compile}, {@link
  188. * compileString}, {@link compileAsync}, and {@link compileStringAsync} instead.
  189. */
  190. export const TRUE: types.Boolean<true>;
  191. /**
  192. * A shorthand for `sass.types.Boolean.FALSE`.
  193. *
  194. * @category Legacy
  195. * @deprecated This only works with the legacy {@link render} and {@link
  196. * renderSync} APIs. Use {@link sassFalse} with {@link compile}, {@link
  197. * compileString}, {@link compileAsync}, and {@link compileStringAsync} instead.
  198. */
  199. export const FALSE: types.Boolean<false>;
  200. /**
  201. * A shorthand for `sass.types.Null.NULL`.
  202. *
  203. * @category Legacy
  204. * @deprecated This only works with the legacy {@link render} and {@link
  205. * renderSync} APIs. Use {@link sassNull} with {@link compile}, {@link
  206. * compileString}, {@link compileAsync}, and {@link compileStringAsync} instead.
  207. */
  208. export const NULL: types.Null;
  209. /**
  210. * The namespace for value types used in the legacy function API.
  211. *
  212. * @category Legacy
  213. * @deprecated This only works with the legacy {@link render} and {@link
  214. * renderSync} APIs. Use {@link Value} with {@link compile}, {@link
  215. * compileString}, {@link compileAsync}, and {@link compileStringAsync} instead.
  216. */
  217. export namespace types {
  218. /**
  219. * The class for Sass's singleton [`null`
  220. * value](https://sass-lang.com/documentation/values/null). The value itself
  221. * can be accessed through the {@link NULL} field.
  222. */
  223. export class Null {
  224. /** Sass's singleton `null` value. */
  225. static readonly NULL: Null;
  226. }
  227. /**
  228. * Sass's [number type](https://sass-lang.com/documentation/values/numbers).
  229. */
  230. export class Number {
  231. /**
  232. * @param value - The numeric value of the number.
  233. *
  234. * @param unit - If passed, the number's unit.
  235. *
  236. * Complex units can be represented as
  237. * `<unit>*<unit>*.../<unit>*<unit>*...`, with numerator units on the
  238. * left-hand side of the `/` and denominator units on the right. A number
  239. * with only numerator units may omit the `/` and the units after it, and a
  240. * number with only denominator units may be represented
  241. * with no units before the `/`.
  242. *
  243. * @example
  244. *
  245. * ```scss
  246. * new sass.types.Number(0.5); // == 0.5
  247. * new sass.types.Number(10, "px"); // == 10px
  248. * new sass.types.Number(10, "px*px"); // == 10px * 1px
  249. * new sass.types.Number(10, "px/s"); // == math.div(10px, 1s)
  250. * new sass.types.Number(10, "px*px/s*s"); // == 10px * math.div(math.div(1px, 1s), 1s)
  251. * ```
  252. */
  253. constructor(value: number, unit?: string);
  254. /**
  255. * Returns the value of the number, ignoring units.
  256. *
  257. * **Heads up!** This means that `96px` and `1in` will return different
  258. * values, even though they represent the same length.
  259. *
  260. * @example
  261. *
  262. * ```js
  263. * const number = new sass.types.Number(10, "px");
  264. * number.getValue(); // 10
  265. * ```
  266. */
  267. getValue(): number;
  268. /**
  269. * Destructively modifies this number by setting its numeric value to
  270. * `value`, independent of its units.
  271. *
  272. * @deprecated Use {@link constructor} instead.
  273. */
  274. setValue(value: number): void;
  275. /**
  276. * Returns a string representation of this number's units. Complex units are
  277. * returned in the same format that {@link constructor} accepts them.
  278. *
  279. * @example
  280. *
  281. * ```js
  282. * // number is `10px`.
  283. * number.getUnit(); // "px"
  284. *
  285. * // number is `math.div(10px, 1s)`.
  286. * number.getUnit(); // "px/s"
  287. * ```
  288. */
  289. getUnit(): string;
  290. /**
  291. * Destructively modifies this number by setting its units to `unit`,
  292. * independent of its numeric value. Complex units are specified in the same
  293. * format as {@link constructor}.
  294. *
  295. * @deprecated Use {@link constructor} instead.
  296. */
  297. setUnit(unit: string): void;
  298. }
  299. /**
  300. * Sass's [string type](https://sass-lang.com/documentation/values/strings).
  301. *
  302. * **Heads up!** This API currently provides no way of distinguishing between
  303. * a [quoted](https://sass-lang.com/documentation/values/strings#quoted) and
  304. * [unquoted](https://sass-lang.com/documentation/values/strings#unquoted)
  305. * string.
  306. */
  307. export class String {
  308. /**
  309. * Creates an unquoted string with the given contents.
  310. *
  311. * **Heads up!** This API currently provides no way of creating a
  312. * [quoted](https://sass-lang.com/documentation/values/strings#quoted)
  313. * string.
  314. */
  315. constructor(value: string);
  316. /**
  317. * Returns the contents of the string. If the string contains escapes,
  318. * those escapes are included literally if it’s
  319. * [unquoted](https://sass-lang.com/documentation/values/strings#unquoted),
  320. * while the values of the escapes are included if it’s
  321. * [quoted](https://sass-lang.com/documentation/values/strings#quoted).
  322. *
  323. * @example
  324. *
  325. * ```
  326. * // string is `Arial`.
  327. * string.getValue(); // "Arial"
  328. *
  329. * // string is `"Helvetica Neue"`.
  330. * string.getValue(); // "Helvetica Neue"
  331. *
  332. * // string is `\1F46D`.
  333. * string.getValue(); // "\\1F46D"
  334. *
  335. * // string is `"\1F46D"`.
  336. * string.getValue(); // "👭"
  337. * ```
  338. */
  339. getValue(): string;
  340. /**
  341. * Destructively modifies this string by setting its numeric value to
  342. * `value`.
  343. *
  344. * **Heads up!** Even if the string was originally quoted, this will cause
  345. * it to become unquoted.
  346. *
  347. * @deprecated Use {@link constructor} instead.
  348. */
  349. setValue(value: string): void;
  350. }
  351. /**
  352. * Sass's [boolean type](https://sass-lang.com/documentation/values/booleans).
  353. *
  354. * Custom functions should respect Sass’s notion of
  355. * [truthiness](https://sass-lang.com/documentation/at-rules/control/if#truthiness-and-falsiness)
  356. * by treating `false` and `null` as falsey and everything else as truthy.
  357. *
  358. * **Heads up!** Boolean values can't be constructed, they can only be
  359. * accessed through the {@link TRUE} and {@link FALSE} constants.
  360. */
  361. export class Boolean<T extends boolean = boolean> {
  362. /**
  363. * Returns `true` if this is Sass's `true` value and `false` if this is
  364. * Sass's `false` value.
  365. *
  366. * @example
  367. *
  368. * ```js
  369. * // boolean is `true`.
  370. * boolean.getValue(); // true
  371. * boolean === sass.types.Boolean.TRUE; // true
  372. *
  373. * // boolean is `false`.
  374. * boolean.getValue(); // false
  375. * boolean === sass.types.Boolean.FALSE; // true
  376. * ```
  377. */
  378. getValue(): T;
  379. /** Sass's `true` value. */
  380. static readonly TRUE: Boolean<true>;
  381. /** Sass's `false` value. */
  382. static readonly FALSE: Boolean<false>;
  383. }
  384. /**
  385. * Sass's [color type](https://sass-lang.com/documentation/values/colors).
  386. */
  387. export class Color {
  388. /**
  389. * Creates a new Sass color with the given red, green, blue, and alpha
  390. * channels. The red, green, and blue channels must be integers between 0
  391. * and 255 (inclusive), and alpha must be between 0 and 1 (inclusive).
  392. *
  393. * @example
  394. *
  395. * ```js
  396. * new sass.types.Color(107, 113, 127); // #6b717f
  397. * new sass.types.Color(0, 0, 0, 0); // rgba(0, 0, 0, 0)
  398. * ```
  399. */
  400. constructor(r: number, g: number, b: number, a?: number);
  401. /**
  402. * Creates a new Sass color with alpha, red, green, and blue channels taken
  403. * from respective two-byte chunks of a hexidecimal number.
  404. *
  405. * @example
  406. *
  407. * ```js
  408. * new sass.types.Color(0xff6b717f); // #6b717f
  409. * new sass.types.Color(0x00000000); // rgba(0, 0, 0, 0)
  410. * ```
  411. */
  412. constructor(argb: number);
  413. /**
  414. * Returns the red channel of the color as an integer from 0 to 255.
  415. *
  416. * @example
  417. *
  418. * ```js
  419. * // color is `#6b717f`.
  420. * color.getR(); // 107
  421. *
  422. * // color is `#b37399`.
  423. * color.getR(); // 179
  424. * ```
  425. */
  426. getR(): number;
  427. /**
  428. * Sets the red channel of the color. The value must be an integer between 0
  429. * and 255 (inclusive).
  430. *
  431. * @deprecated Use {@link constructor} instead.
  432. */
  433. setR(value: number): void;
  434. /**
  435. * Returns the green channel of the color as an integer from 0 to 255.
  436. *
  437. * @example
  438. *
  439. * ```js
  440. * // color is `#6b717f`.
  441. * color.getG(); // 113
  442. *
  443. * // color is `#b37399`.
  444. * color.getG(); // 115
  445. * ```
  446. */
  447. getG(): number;
  448. /**
  449. * Sets the green channel of the color. The value must be an integer between
  450. * 0 and 255 (inclusive).
  451. *
  452. * @deprecated Use {@link constructor} instead.
  453. */
  454. setG(value: number): void;
  455. /**
  456. * Returns the blue channel of the color as an integer from 0 to 255.
  457. *
  458. * @example
  459. *
  460. * ```js
  461. * // color is `#6b717f`.
  462. * color.getB(); // 127
  463. *
  464. * // color is `#b37399`.
  465. * color.getB(); // 153
  466. * ```
  467. */
  468. getB(): number;
  469. /**
  470. * Sets the blue channel of the color. The value must be an integer between
  471. * 0 and 255 (inclusive).
  472. *
  473. * @deprecated Use {@link constructor} instead.
  474. */
  475. setB(value: number): void;
  476. /**
  477. * Returns the alpha channel of the color as a number from 0 to 1.
  478. *
  479. * @example
  480. *
  481. * ```js
  482. * // color is `#6b717f`.
  483. * color.getA(); // 1
  484. *
  485. * // color is `transparent`.
  486. * color.getA(); // 0
  487. * ```
  488. */
  489. getA(): number;
  490. /**
  491. * Sets the alpha channel of the color. The value must be between 0 and 1
  492. * (inclusive).
  493. *
  494. * @deprecated Use {@link constructor} instead.
  495. */
  496. setA(value: number): void;
  497. }
  498. /**
  499. * Sass's [list type](https://sass-lang.com/documentation/values/lists).
  500. *
  501. * **Heads up!** This list type’s methods use 0-based indexing, even though
  502. * within Sass lists use 1-based indexing. These methods also don’t support
  503. * using negative numbers to index backwards from the end of the list.
  504. */
  505. export class List {
  506. /**
  507. * Creates a new Sass list.
  508. *
  509. * **Heads up!** The initial values of the list elements are undefined.
  510. * These elements must be set using {@link setValue} before accessing them
  511. * or passing the list back to Sass.
  512. *
  513. * @example
  514. *
  515. * ```js
  516. * const list = new sass.types.List(3);
  517. * list.setValue(0, new sass.types.Number(10, "px"));
  518. * list.setValue(1, new sass.types.Number(15, "px"));
  519. * list.setValue(2, new sass.types.Number(32, "px"));
  520. * list; // 10px, 15px, 32px
  521. * ```
  522. *
  523. * @param length - The number of (initially undefined) elements in the list.
  524. * @param commaSeparator - If `true`, the list is comma-separated; otherwise,
  525. * it's space-separated. Defaults to `true`.
  526. */
  527. constructor(length: number, commaSeparator?: boolean);
  528. /**
  529. * Returns the element at `index`, or `undefined` if that value hasn't yet
  530. * been set.
  531. *
  532. * @example
  533. *
  534. * ```js
  535. * // list is `10px, 15px, 32px`
  536. * list.getValue(0); // 10px
  537. * list.getValue(2); // 32px
  538. * ```
  539. *
  540. * @param index - A (0-based) index into this list.
  541. * @throws `Error` if `index` is less than 0 or greater than or equal to the
  542. * number of elements in this list.
  543. */
  544. getValue(index: number): LegacyValue | undefined;
  545. /**
  546. * Sets the element at `index` to `value`.
  547. *
  548. * @example
  549. *
  550. * ```js
  551. * // list is `10px, 15px, 32px`
  552. * list.setValue(1, new sass.types.Number(18, "px"));
  553. * list; // 10px, 18px, 32px
  554. * ```
  555. *
  556. * @param index - A (0-based) index into this list.
  557. * @throws `Error` if `index` is less than 0 or greater than or equal to the
  558. * number of elements in this list.
  559. */
  560. setValue(index: number, value: LegacyValue): void;
  561. /**
  562. * Returns `true` if this list is comma-separated and `false` otherwise.
  563. *
  564. * @example
  565. *
  566. * ```js
  567. * // list is `10px, 15px, 32px`
  568. * list.getSeparator(); // true
  569. *
  570. * // list is `1px solid`
  571. * list.getSeparator(); // false
  572. * ```
  573. */
  574. getSeparator(): boolean;
  575. /**
  576. * Sets whether the list is comma-separated.
  577. *
  578. * @param isComma - `true` to make the list comma-separated, `false` otherwise.
  579. */
  580. setSeparator(isComma: boolean): void;
  581. /**
  582. * Returns the number of elements in the list.
  583. *
  584. * @example
  585. *
  586. * ```js
  587. * // list is `10px, 15px, 32px`
  588. * list.getLength(); // 3
  589. *
  590. * // list is `1px solid`
  591. * list.getLength(); // 2
  592. * ```
  593. */
  594. getLength(): number;
  595. }
  596. /**
  597. * Sass's [map type](https://sass-lang.com/documentation/values/maps).
  598. *
  599. * **Heads up!** This map type is represented as a list of key-value pairs
  600. * rather than a mapping from keys to values. The only way to find the value
  601. * associated with a given key is to iterate through the map checking for that
  602. * key. Maps created through this API are still forbidden from having duplicate
  603. * keys.
  604. */
  605. export class Map {
  606. /**
  607. * Creates a new Sass map.
  608. *
  609. * **Heads up!** The initial keys and values of the map are undefined. They
  610. * must be set using {@link setKey} and {@link setValue} before accessing
  611. * them or passing the map back to Sass.
  612. *
  613. * @example
  614. *
  615. * ```js
  616. * const map = new sass.types.Map(2);
  617. * map.setKey(0, new sass.types.String("width"));
  618. * map.setValue(0, new sass.types.Number(300, "px"));
  619. * map.setKey(1, new sass.types.String("height"));
  620. * map.setValue(1, new sass.types.Number(100, "px"));
  621. * map; // (width: 300px, height: 100px)
  622. * ```
  623. *
  624. * @param length - The number of (initially undefined) key/value pairs in the map.
  625. */
  626. constructor(length: number);
  627. /**
  628. * Returns the value in the key/value pair at `index`.
  629. *
  630. * @example
  631. *
  632. * ```js
  633. * // map is `(width: 300px, height: 100px)`
  634. * map.getValue(0); // 300px
  635. * map.getValue(1); // 100px
  636. * ```
  637. *
  638. * @param index - A (0-based) index of a key/value pair in this map.
  639. * @throws `Error` if `index` is less than 0 or greater than or equal to the
  640. * number of pairs in this map.
  641. */
  642. getValue(index: number): LegacyValue;
  643. /**
  644. * Sets the value in the key/value pair at `index` to `value`.
  645. *
  646. * @example
  647. *
  648. * ```js
  649. * // map is `("light": 200, "medium": 400, "bold": 600)`
  650. * map.setValue(1, new sass.types.Number(300));
  651. * map; // ("light": 200, "medium": 300, "bold": 600)
  652. * ```
  653. *
  654. * @param index - A (0-based) index of a key/value pair in this map.
  655. * @throws `Error` if `index` is less than 0 or greater than or equal to the
  656. * number of pairs in this map.
  657. */
  658. setValue(index: number, value: LegacyValue): void;
  659. /**
  660. * Returns the key in the key/value pair at `index`.
  661. *
  662. * @example
  663. *
  664. * ```js
  665. * // map is `(width: 300px, height: 100px)`
  666. * map.getKey(0); // width
  667. * map.getKey(1); // height
  668. * ```
  669. *
  670. * @param index - A (0-based) index of a key/value pair in this map.
  671. * @throws `Error` if `index` is less than 0 or greater than or equal to the
  672. * number of pairs in this map.
  673. */
  674. getKey(index: number): LegacyValue;
  675. /**
  676. * Sets the value in the key/value pair at `index` to `value`.
  677. *
  678. * @example
  679. *
  680. * ```js
  681. * // map is `("light": 200, "medium": 400, "bold": 600)`
  682. * map.setValue(1, new sass.types.String("lighter"));
  683. * map; // ("lighter": 200, "medium": 300, "bold": 600)
  684. * ```
  685. *
  686. * @param index - A (0-based) index of a key/value pair in this map.
  687. * @throws `Error` if `index` is less than 0 or greater than or equal to the
  688. * number of pairs in this map.
  689. */
  690. setKey(index: number, key: LegacyValue): void;
  691. /**
  692. * Returns the number of key/value pairs in this map.
  693. *
  694. * @example
  695. *
  696. * ```js
  697. * // map is `("light": 200, "medium": 400, "bold": 600)`
  698. * map.getLength(); // 3
  699. *
  700. * // map is `(width: 300px, height: 100px)`
  701. * map.getLength(); // 2
  702. * ```
  703. */
  704. getLength(): number;
  705. }
  706. /**
  707. * An error that can be returned from a Sass function to signal that it
  708. * encountered an error. This is the only way to signal an error
  709. * asynchronously from a {@link LegacyAsyncFunction}.
  710. */
  711. export class Error {
  712. constructor(message: string);
  713. }
  714. }