SassFunction
Sass'sfunction type.
⚠️ Heads up!
Although first-class Sass functions can be processed by customfunctions, there’s no way to invoke them outside of a Sass stylesheet.
Hierarchy
- Value
- SassFunction
- Defined injs-api-doc/value/function.d.ts:11
Constructors
constructor
- new
Sass Function(signature:string,callback:((args:Value[]) =>Value)):SassFunction Creates a new first-class function that can be invoked using
meta.call()
.Parameters
signature:string
The function signature, like you'd write for the
@function rule
.callback:((args:Value[]) =>Value)
The callback that's invoked when this function is called,just like for aCustomFunction.
ReturnsSassFunction
OverridesValue.constructor
- Defined injs-api-doc/value/function.d.ts:21
Accessors
as List
- get asList():List<Value>
This value as a list.
All SassScript values can be used as lists. Maps count as lists of pairs,and all other values count as single-value lists.
ReturnsList<Value>
An immutable List from the
immutable
package.Inherited from Value.asList
- Defined injs-api-doc/value/index.d.ts:77
has Brackets
- get hasBrackets():boolean
Whether this value as a list has brackets.
All SassScript values can be used as lists. Maps count as lists of pairs,and all other values count as single-value lists.
Returnsboolean
Inherited from Value.hasBrackets
- Defined injs-api-doc/value/index.d.ts:85
is Truthy
- get isTruthy():boolean
Whether the value counts as
true
in an@if
statement and other contexts.Returnsboolean
Inherited from Value.isTruthy
- Defined injs-api-doc/value/index.d.ts:91
real Null
- get realNull():null |Value
Returns JavaScript's
null
value if this issassNull, and returnsthis
otherwise.Returnsnull |Value
Inherited from Value.realNull
- Defined injs-api-doc/value/index.d.ts:97
separator
- get separator():ListSeparator
The separator for this value as a list.
All SassScript values can be used as lists. Maps count as lists of pairs,and all other values count as single-value lists.
ReturnsListSeparator
Inherited from Value.separator
- Defined injs-api-doc/value/index.d.ts:105
Methods
assert Boolean
- assert
Boolean(name?:string):SassBoolean Throws if
this
isn't aSassBoolean.⚠️ Heads up!
Functions should generally useisTruthy rather thanrequiring a literal boolean.
Parameters
Optional
name:stringThe name of the function argument
this
came from (withoutthe$
) if it came from an argument. Used for error reporting.
ReturnsSassBoolean
Inherited fromValue.assertBoolean
- Defined injs-api-doc/value/index.d.ts:147
assert Calculation
- assert
Calculation(name?:string):SassCalculation Throws if
this
isn't aSassCalculation.Parameters
Optional
name:stringThe name of the function argument
this
came from (withoutthe$
) if it came from an argument. Used for error reporting.
ReturnsSassCalculation
Inherited fromValue.assertCalculation
- Defined injs-api-doc/value/index.d.ts:155
assert Color
- assert
Color(name?:string):SassColor Throws if
this
isn't aSassColor.Parameters
Optional
name:stringThe name of the function argument
this
came from (withoutthe$
) if it came from an argument. Used for error reporting.
ReturnsSassColor
Inherited fromValue.assertColor
- Defined injs-api-doc/value/index.d.ts:163
assert Function
- assert
Function(name?:string):SassFunction Throws if
this
isn't aSassFunction.Parameters
Optional
name:stringThe name of the function argument
this
came from (withoutthe$
) if it came from an argument. Used for error reporting.
ReturnsSassFunction
Inherited fromValue.assertFunction
- Defined injs-api-doc/value/index.d.ts:171
assert Map
- assert
Map(name?:string):SassMap Throws if
this
isn't aSassMap.Parameters
Optional
name:stringThe name of the function argument
this
came from (withoutthe$
) if it came from an argument. Used for error reporting.
ReturnsSassMap
- Defined injs-api-doc/value/index.d.ts:179
assert Mixin
- assert
Mixin(name?:string):SassMixin Throws if
this
isn't aSassMixin.Parameters
Optional
name:stringThe name of the function argument
this
came from (withoutthe$
) if it came from an argument. Used for error reporting.
ReturnsSassMixin
Inherited fromValue.assertMixin
- Defined injs-api-doc/value/index.d.ts:187
assert Number
- assert
Number(name?:string):SassNumber Throws if
this
isn't aSassNumber.Parameters
Optional
name:stringThe name of the function argument
this
came from (withoutthe$
) if it came from an argument. Used for error reporting.
ReturnsSassNumber
Inherited fromValue.assertNumber
- Defined injs-api-doc/value/index.d.ts:195
assert String
- assert
String(name?:string):SassString Throws if
this
isn't aSassString.Parameters
Optional
name:stringThe name of the function argument
this
came from (withoutthe$
) if it came from an argument. Used for error reporting.
ReturnsSassString
Inherited fromValue.assertString
- Defined injs-api-doc/value/index.d.ts:203
equals
- equals(other:Value):boolean
Returns whether
this
represents the same value asother
.Parameters
other:Value
Returnsboolean
- Defined injs-api-doc/value/index.d.ts:212
get
- get(index:number):undefined |Value
Returns the value at index
index
in this value as a list, orundefined
ifindex
isn't valid for this list.All SassScript values can be used as lists. Maps count as lists of pairs,and all other values count as single-value lists.
This is a shorthand for
this.asList.get(index)
, although it may be moreefficient in some cases.⚠️ Heads up!
This method uses the same indexing conventions as the
immutable
package: unlike Sass the index of the first element is 0, butlike Sass negative numbers index from the end of the list.Parameters
index:number
Returnsundefined |Value
- Defined injs-api-doc/value/index.d.ts:136
hash Code
- hash
Code():number Returns a hash code that can be used to store
this
in a hash map.Returnsnumber
- Defined injs-api-doc/value/index.d.ts:215
sass Index To List Index
- sass
Index To List Index(sassIndex:Value,name?:string):number Converts
sassIndex
into a JavaScript-style index into the list returnedbyasList.Sass indexes are one-based, while JavaScript indexes are zero-based. Sassindexes may also be negative in order to index from the end of the list.
Throws
Error
IfsassIndex
isn't a number, if that number isn't aninteger, or if that integer isn't a valid index forasList.Parameters
sassIndex:Value
The Sass-style index into this as a list.
Optional
name:stringThe name of the function argument
sassIndex
came from(without the$
) if it came from an argument. Used for error reporting.
Returnsnumber
Inherited fromValue.sassIndexToListIndex
- Defined injs-api-doc/value/index.d.ts:120
try Map
- try
Map():null |SassMap Returns
this
as a map if it counts as one (empty lists count as emptymaps) ornull
if it doesn't.Returnsnull |SassMap
- Defined injs-api-doc/value/index.d.ts:209