/** Copyright 2023 Infosys Ltd. */
NGX-CUSTOM-PIPE
Demo.
Visit here to viewString related pipes:
Below string pipes are available as a part of this library:
- upper
- lower
- trim
- split
- replace
- match
- mask
- normalize
- capitalize
- slugIt
- reverse
- repeat
- interpolate
- truncate
- deLatinize
Examples:
- Code: 'I am invincible' | upper
Input: I am invincible
Output: I AM INVINCIBLE
#Convert a string to Uppercase.
- Code: 'I AM A PORSCHE with NO BREAK' | lower
Input: I AM A PORSCHE with NO BREAK
Output: i am a porsche with no break
#Convert a string to Lowercase.
- Code: ' 45a ' | trim: 'left' - PERMISSIBLE VALUES - 'left', 'right', 'start', 'end', 'around'
Input: 45a
Output: 45a #Notice the spacing
#'left' is an Optional Direction. Default is 'around'. Other permissible values are 'left', 'right', 'start', 'end' and 'around'.
- Code: '45a 67b' | split: ' '
Input: 45a 67b
Output: 45a,67b
#' ' is an Optional Separator. Default is ''.
- Code: 'Here should be replaced by There' | replace: 'Here': 'There'
Input: Here should be replaced by There
Output: There should be replaced by There
#'There' is Optional Replaced String. Default is 'Default Text'.
- Code: 'We have to get the first occurrence of the matching sub strings in the string. Matching string should be the[case insensitive]' | match: 'the'
Input: We have to get the first occurrence of the matching sub strings in the string. Matching string should be the[case insensitive]
Output: 15
#'the' represents the text which shall be available in the string. It returns the index of first occurence.
- Code: '121212121212' | mask
Input: '121212121212'
Output: XXXXXXXXXXXX
- Code: '121212121212' | mask: 8: 'left'
Input: '121212121212'
Output: XXXXXXXX1212
- Code: '121212121212' | mask: 8: 'right'
Input: '121212121212'
Output: 1212XXXXXXXX
#This pipe returns the masked value of a string. 8 and 'left' or 'right' is optional arguements. 8 is the number of charaters to be masked. By default, it's same as input length. Second arguement represents diretion of masking(from left/right). By default, it's 'right'.
- Code: 'rajneeshKumar, petchiKannan and akshayShinde are the developer-of-this_library.' | normalize
Input: 'rajneeshKumar, petchiKannan and akshayShinde are the developer-of-this_library.'
Output: Rajneesh Kumar, Petchi Kannan And Akshay Shinde Are The Developer Of This Library.
#This pipe returns the well organized sentance formed after capitalizing first letter of each word, replacing - or _ with spaces and by separating camelCases and PascalCases.
- Code: 'We have to cApitalize this string.' | capitalize
Input: We have to cApitalize this string.
Output: We Have To Capitalize This String.
#It Makes The First Letter Of Each Word in a String Capital.
- Code: 'We have to slug this string.' | slugIt
Input: We have to slug this string.
Output: we-have-to-slug-this-string-
#This pipe replaces spaces and special characters with hyphens.
- Code: 'string to reverse' | reverse
Input: string to reverse
Output: esrever ot gnirts
#This pipe reverses the input string.
- Code: 'string to repeat' | repeat: 5: '-'
Input: string to repeat
Output: string to repeat-string to repeat-string to repeat-string to repeat-string to repeat
#This pipe repeats the string for n times joined by separator. 5 is optional count and '-' is optional separator. Default count is 1 and default separator is ''.
- Code: 'I want to {0} these {1} using {2} pipe.' | interpolate: 'populate': 'strings': 'interpolate'
Input: I want to {0} these {1} using {2} pipe.
Output: I want to populate these strings using interpolate pipe.
#This pipe reverses the input string.
- Code: 'string to truncate after 15 digits' | truncate: 15: '- - -'
Input: string to truncate after 15 digits
Output: string to trunc- - -
#This pipe truncates the input string to given number of characters with provided delimiter. Default numer is half of the string's length and default delimiter is '...'.
- Code: 'şᵵᵲᶖnɡ to delaᵵᶖnᶖze' | deLatinize
Input: şᵵᵲᶖnɡ to delaᵵᶖnᶖze
Output: string to delatinize
#This pipe de-latinize the input string.
Aggregation related pipes:
Below aggregation pipes are available as a part of this library:
- groupBy
- average
- median
- mode
- minimum
- maximum
- sum
Examples:
- Code in TS: public data: any[] = [ {name: 'Adam', prof: 'Teacher'}, {name: 'Brian', prof: 'Housekeeper'}, {name: 'Chloe', prof: 'Teacher'}, {name: 'Daren', prof: 'Gardener'} ]
- Template Code: data | groupBy: 'prof' | stringify
Input: [ {name: 'Adam', prof: 'Teacher'}, {name: 'Brian', prof: 'Housekeeper'}, {name: 'Chloe', prof: 'Teacher'}, {name: 'Daren', prof: 'Gardener'} ]
Output: [{"key":"Teacher","value":[{"name":"Adam","prof":"Teacher"},{"name":"Chloe","prof":"Teacher"}]},{"key":"Housekeeper","value":[{"name":"Brian","prof":"Housekeeper"}]},{"key":"Gardener","value":[{"name":"Daren","prof":"Gardener"}]}]
'prof' column represents column to be used for grouping. Additionally, stringify pipe has been used to render data after converting it from Object to String.
- Code: [3, 5, 7, 12, 5] | average
Input: [3, 5, 7, 12, 5]
Output: 6.4
#This pipe strictly asks for an array of number as input, and returns a number as average of all the values of array.
- Code: [3, 5, 7, 12, 5] | median
Input: [3, 5, 7, 12, 5]
Output: 5
#This pipe strictly asks for an array of number as input, and returns a number as median of all the values of array.
- Code: [3, 5, 7, 12, 5] | mode
Input: [3, 5, 7, 12, 5]
Output: 5
#This pipe strictly asks for an array of number as input, and returns a number as mode of all the values of array.
- Code: [3, 5, 7, 12, 5] | minimum
Input: [3, 5, 7, 12, 5]
Output: 3
#This pipe strictly asks for an array of number as input, and returns a number as minimum of all the values of array.
- Code: [3, 5, 7, 12, 5] | maximum
Input: [3, 5, 7, 12, 5]
Output: 12
#This pipe strictly asks for an array of number as input, and returns a number as maximum of all the values of array.
- Code: [3, 5, 7, 12, 5] | sum
Input: [3, 5, 7, 12, 5]
Output: 32
#This pipe strictly asks for an array of number as input, and returns a number as sum of all the values of array.
Collections related pipes:
Below array pipes are available as a part of this library:
- empty
- firstItem
- lastItem
- popFirstItem
- popLastItem
- join
- combine
- set
- except
- and
- or
- range
- map
- pluckProperty
- filter
- filterOne
- sort
- reverseArray
- length
- chunk
- drop
- flat
Examples:
- Code: [] | empty
Input: []
Output: true
- Code: [3, 5, 7, 12, 5] | empty
Input: [3, 5, 7, 12, 5]
Output: false
#This pipe returns a boolean denoting the empty state of any array.
- Code: [3, 5, 7, "12", 5] | firstItem
Input: [3, 5, 7, "12", 5]
Output: 3
#This pipe takes an array as input, and returns the first element of the array.
- Code: [3, 5, 7, "12", 5] | lastItem
Input: [3, 5, 7, "12", 5]
Output: 5
#This pipe takes an array as input, and returns the last element of the array.
- Code: [3, 5, 7, "12", 5] | popFirstItem
Input: [3, 5, 7, "12", 5]
Output: [5,7,"12",5]
#This pipe takes an array as input, and returns the array without first element of the array.
- Code: [3, 5, 7, "12", 5] | popLastItem
Input: [3, 5, 7, "12", 5]
Output: [3,5,7,"12"]
#This pipe takes an array as input, and returns the array without last element of the array.
- Code: ["Devil", "was", "at age of", "12", "When he joined the ", "."] | join: "Coders"
Input: ["Devil", "was", "at age of", "12", "When he joined the ", "."]
Output: DevilCoderswasCodersat age ofCoders12CodersWhen he joined the Coders.
#This pipe takes an array of string as input, and returns a string joining the array with the provided joiner. 'Coders' is an optional joiner. Default is ''.
- Code: [3, 5, 7, "12", 5] | combine: [5, "Ram"]
Input: [3, 5, 7, "12", 5]
Output: [3,5,7,"12",5,5,"Ram"]
#This pipe reverses the input string.
- Code: [3, 5, 7, "12", 5] | set
Input: [3, 5, 7, "12", 5]
Output: [3,5,7,"12"]
#This pipe takes an array as input, and returns an array with unique elements of the array.
- Code: [3, 5, 7, "12", 5] | except: [5, "12"]
Input: [3, 5, 7, "12", 5]
Output: [3,7]
- Code: [3, 5, 7, "12", 5] | except: 5
Input: [3, 5, 7, "12", 5]
Output: [3,7,"12"]
- Code: [3, 5, 7, "12", 5] | except: "12"
Input: [3, 5, 7, "12", 5]
Output: [3,5,7,5]
#This pipe takes an array/string/number as input, and returns an array without mentioned elements of the array.
- Code: [3, 5, 7, "12", 5] | and: [5, "12", 1, "Ram"]
Input: [3, 5, 7, "12", 5]
Output: [5,"12"]
#This pipe takes an array as input, and returns an intersection with mentioned array[No duplicates in result].
- Code: [3, 5, 7, "12", 5] | or: [5, "12", 1, "Ram"]
Input: [3, 5, 7, "12", 5]
Output: [3,5,7,"12",1,"Ram"]
#This pipe takes an array as input, and returns a union with mentioned array[No duplicates in result].
- Code: [3, 5, 7, 12, 5, 107] | range: 5: 50
Input: [3, 5, 7, 12, 5, 107]
Output: [5,7,12,5]
#This pipe takes an array of number as input, and returns an array with all the elements in provided range[both inclusive]. Both start[5] and end[50] values are optional, it takes minimum and maximum value of the array respectively, if ommitted.
- Code in TS: public mapFunction(input) { return input + input; }
- Template Code: [3, 5, 7, 12, 5, 107] | map: mapFunction
Input: [3, 5, 7, 12, 5, 107]
Output: [6,10,14,24,10,214]
#This pipe takes an array of number as input, and returns an array after performing function operation on it.
- Code: [ {name: 'Alex', details: {official: {designation: 'Coder', organization: 'AB CORP.'}, personal: {aadhar: '111122223333', pan: 'ABCDE1234F'}}}, {name: 'Ben', details: {official: {designation: 'Coder', organization: 'AB CORP.'}, personal: {aadhar: '222233334444', pan: 'GHIJ1234K'}}}, {name: 'Ceth', details: {official: {designation: 'Coder', organization: 'AB CORP.'}, personal: {aadhar: '333344445555', pan: 'LMNO1234P'}}} ] | pluckProperty: 'details.personal.aadhar'
Input: [ {name: 'Alex', details: {official: {designation: 'Coder', organization: 'AB CORP.'}, personal: {aadhar: '111122223333', pan: 'ABCDE1234F'}}}, {name: 'Ben', details: {official: {designation: 'Coder', organization: 'AB CORP.'}, personal: {aadhar: '222233334444', pan: 'GHIJ1234K'}}}, {name: 'Ceth', details: {official: {designation: 'Coder', organization: 'AB CORP.'}, personal: {aadhar: '333344445555', pan: 'LMNO1234P'}}} ]
Output: ["111122223333","222233334444","333344445555"]
#This pipe takes an array of number as input, and returns an array of mentioned key from it.
- Code: [3, 5, 7, 12, 5, 107] | filter: 5
Input: [3, 5, 7, 12, 5, 107]
Output: [5,5]
- Code: ["3", 5, 7, "12", 5, 107] | filter: "12"
Input: ["3", 5, 7, "12", 5, 107]
Output: ["12"]
- Code: [ {name: 'Alex', details: {official: {designation: 'Coder', organization: 'AB CORP.'}, personal: {aadhar: '111122223333', pan: 'ABCDE1234F'}}}, {name: 'Ben', details: {official: {designation: 'Coder', organization: 'AB CORP.'}, personal: {aadhar: '222233334444', pan: 'GHIJ1234K'}}}, {name: 'Ceth', details: {official: {designation: 'Tester', organization: 'AB CORP.'}, personal: {aadhar: '333344445555', pan: 'LMNO1234P'}}} ] | filter: ['details.official.designation', 'Coder']
Input: [ {name: 'Alex', details: {official: {designation: 'Coder', organization: 'AB CORP.'}, personal: {aadhar: '111122223333', pan: 'ABCDE1234F'}}}, {name: 'Ben', details: {official: {designation: 'Coder', organization: 'AB CORP.'}, personal: {aadhar: '222233334444', pan: 'GHIJ1234K'}}}, {name: 'Ceth', details: {official: {designation: 'Tester', organization: 'AB CORP.'}, personal: {aadhar: '333344445555', pan: 'LMNO1234P'}}} ]
Output: [{"name":"Alex","details":{"official":{"designation":"Coder","organization":"AB CORP."},"personal":{"aadhar":"111122223333","pan":"ABCDE1234F"}}},{"name":"Ben","details":{"official":{"designation":"Coder","organization":"AB CORP."},"personal":{"aadhar":"222233334444","pan":"GHIJ1234K"}}}]
- Code: [ {name: 'Alex', details: {official: {designation: 'Coder', organization: 'AB CORP.'}, personal: {aadhar: '111122223333', pan: 'ABCDE1234F'}}}, {name: 'Ben', details: {official: {designation: 'Coder', organization: 'AB CORP.'}, personal: {aadhar: '222233334444', pan: 'GHIJ1234K'}}}, {name: 'Ceth', details: {official: {designation: 'Tester', organization: 'AB CORP.'}, personal: {aadhar: '333344445555', pan: 'LMNO1234P'}}} ] | filter: filterFunction
Input: [ {name: 'Alex', details: {official: {designation: 'Coder', organization: 'AB CORP.'}, personal: {aadhar: '111122223333', pan: 'ABCDE1234F'}}}, {name: 'Ben', details: {official: {designation: 'Coder', organization: 'AB CORP.'}, personal: {aadhar: '222233334444', pan: 'GHIJ1234K'}}}, {name: 'Ceth', details: {official: {designation: 'Tester', organization: 'AB CORP.'}, personal: {aadhar: '333344445555', pan: 'LMNO1234P'}}} ]
Output: [{"name":"Alex","details":{"official":{"designation":"Coder","organization":"AB CORP."},"personal":{"aadhar":"111122223333","pan":"ABCDE1234F"}}}]
#This pipe takes an array as input, and returns a filtered array according to parameterized value/function.
- Code: [3, 5, 7, 12, 5, 107] | filter: 5
Input: [3, 5, 7, 12, 5, 107]
Output: 5
- Code: ["3", 5, 7, "12", 5, 107] | filterOne: "12"
Input: ["3", 5, 7, "12", 5, 107]
Output: "12"
- Code: [ {name: 'Alex', details: {official: {designation: 'Coder', organization: 'AB CORP.'}, personal: {aadhar: '111122223333', pan: 'ABCDE1234F'}}}, {name: 'Ben', details: {official: {designation: 'Coder', organization: 'AB CORP.'}, personal: {aadhar: '222233334444', pan: 'GHIJ1234K'}}}, {name: 'Ceth', details: {official: {designation: 'Tester', organization: 'AB CORP.'}, personal: {aadhar: '333344445555', pan: 'LMNO1234P'}}} ] | filterOne: ['details.official.designation', 'Coder']
Input: [ {name: 'Alex', details: {official: {designation: 'Coder', organization: 'AB CORP.'}, personal: {aadhar: '111122223333', pan: 'ABCDE1234F'}}}, {name: 'Ben', details: {official: {designation: 'Coder', organization: 'AB CORP.'}, personal: {aadhar: '222233334444', pan: 'GHIJ1234K'}}}, {name: 'Ceth', details: {official: {designation: 'Tester', organization: 'AB CORP.'}, personal: {aadhar: '333344445555', pan: 'LMNO1234P'}}} ]
Output: {"name":"Alex","details":{"official":{"designation":"Coder","organization":"AB CORP."},"personal":{"aadhar":"111122223333","pan":"ABCDE1234F"}}}
- Code: [ {name: 'Alex', details: {official: {designation: 'Coder', organization: 'AB CORP.'}, personal: {aadhar: '111122223333', pan: 'ABCDE1234F'}}}, {name: 'Ben', details: {official: {designation: 'Coder', organization: 'AB CORP.'}, personal: {aadhar: '222233334444', pan: 'GHIJ1234K'}}}, {name: 'Ceth', details: {official: {designation: 'Tester', organization: 'AB CORP.'}, personal: {aadhar: '333344445555', pan: 'LMNO1234P'}}} ] | filterOne: filterFunction
Input: [ {name: 'Alex', details: {official: {designation: 'Coder', organization: 'AB CORP.'}, personal: {aadhar: '111122223333', pan: 'ABCDE1234F'}}}, {name: 'Ben', details: {official: {designation: 'Coder', organization: 'AB CORP.'}, personal: {aadhar: '222233334444', pan: 'GHIJ1234K'}}}, {name: 'Ceth', details: {official: {designation: 'Tester', organization: 'AB CORP.'}, personal: {aadhar: '333344445555', pan: 'LMNO1234P'}}} ]
Output: {"name":"Alex","details":{"official":{"designation":"Coder","organization":"AB CORP."},"personal":{"aadhar":"111122223333","pan":"ABCDE1234F"}}}
#This pipe takes an array as input, and returns only one element according to parameterized value/function.
- Code: [3, 5, 7, 12, 5, 107] | sort: 'desc' - PERMISSIBLE VALUES - 'asc', 'desc'
Input: [3, 5, 7, 12, 5, 107]
Output: [107,12,7,5,5,3]
#This pipe takes an array as input, and returns sorted array. 'desc' is optional sorting method parameter. Default is 'asc'.
- Code: [3, 5, 7, 12, 5, 107] | reverseArray
Input: [3, 5, 7, 12, 5, 107]
Output: [107,5,12,7,5,3]
#This pipe takes an array as input, and returns reversed array.
- Code: [3, 5, 7, 12, 5, 107] | length
Input: [3, 5, 7, 12, 5, 107]
Output: 6
#This pipe takes an array as input, and returns its length.
- Code: [3, 5, 7, 12, 5, 107, "Glamour"] | chunk: 3
Input: [3, 5, 7, 12, 5, 107, "Glamour"]
Output: [[3,5,7],[12,5,107],["Glamour"]]
#This pipe takes an array as input, and returns an array containing smaller arrays of given length. 3 is an optional length parameter. Default is 1.
- Code: [3, 5, 7, 12, 5, 107, "Glamour"] | drop: 3
Input: [3, 5, 7, 12, 5, 107, "Glamour"]
Output: [3,5,7,12]
#This pipe takes an array as input, and returns an array with last n values deleted. 3 is an optional drop parameter. Default is 1.
- Code: [3, [5, 7], [12, [[5], [107, "Glamour"]]]] | flat: 2
Input: [3, [5, 7], [12, [[5], [107, "Glamour"]]]]
Output: [3,5,7,12,[5],[107,"Glamour"]]
#This pipe takes an array as input, and returns an array after flattening it to given layers. 2 is an optional layer parameter. Default is 1.
Number/Conversion related pipes:
Below number pipes are available as a part of this library:
- byteConvertTo
- convertToBase
- convertToWord
- ceil
- floor
- handleNan
- round
- toDegree
- toRadian
- power
- sqroot
- absolute
- integerType
- ordinal
Examples:
- Code: 450009856 | byteConvertTo: 'KB' - PERMISSIBLE VALUES - 'B', 'KB', 'MB', 'GB', 'TB'
Input: 450009856
Output: 439462.75 KB
#'KB' is an Optional Message. Other permissible values are 'B'(Bytes), 'KB'(KiloBytes), 'MB'(MegaBytes), 'GB'(GigaBytes) and 'TB'(TeraBytes).
- Code: 45 | convertToBase: 'decimal': 2 - PERMISSIBLE VALUES - 'binary', 'octal', 'decimal', 'hexadecimal', ANY NUMBER
Input: 45
Output: 101101
- Code: '1001' | convertToBase: 2: 'octal'
Input: 1001
Output: 11
- Code: 45 | convertToBase: 10: 'hexadecimal'
Input: 45
Output: 2d
- Code: 10 | convertToBase: 'octal': 10
Input: 10
Output: 8
#This pipe converts input number/string from one base to another. First parameter is the base of input. Second parameter is the base of output. These bases could be either a number or 'binary' or 'octal' or 'decimal' or 'hexadecimal'[See Example].
- Code: 450090856.64848939302323245245523232 | convertToWord
Input: 450090856.64848939302323245245523232
Output: Four Hundred Fifty Million Ninety Thousand Eight Hundred Fifty Six point Six Four Eight Four Eight Nine Four
- Code: 450090856 | convertToWord: 'USA'
Input: 450090856
Output: Four Hundred Fifty Million Ninety Thousand Eight Hundred Fifty Six
- Code: 450009856 | convertToWord: 'IND'
Input: 450009856
Output: Forty Five Crore Nine Thousand Eight Hundred Fifty Six
#This pipe returns the calculated word value upto 21 digits and rounded 7 digits after decimal. 'USA' or 'IND' is optional number system. Default is 'USA'.</div>
- Code: 99.45 | ceil
Input: 99.45
Output: 100
#This pipe returns the next integer to provided value.
- Code: 99.45 | floor
Input: 99.45
Output: 99
#This pipe returns the previous integer to provided value.
- Code: '45a' | handleNan: 'Not a Number'
Input: 45a
Output: Not a Number
#'Not a Number' is an Optional Message. Default is 'Invalid Number'.
- Code: 44.555 | round
Input: 44.555
Output: 44.6
#This pipe returns the rounded value to provided value upto given decimal digits. 1 is optional number of digits post decimal. Default is 0.
- Code: 3.147 | toDegree
Input: 3.147
Output: 180.30981812767004
#This pipe converts radians into degrees.
- Code: 720 | toRadian
Input: 720
Output: 4π
#This pipe converts degrees into radians.
- Code: 90 | power: 3
Input: 90
Output: 729000
#This pipe returns the calculated power value. 3 is optional exponent. Default is 0.
- Code: 1024 | sqroot
Input: 1024
Output: 32
#This pipe returns the square root of provided value.
- Code: -20 | absolute
Input: -20
Output: 20
#This pipe returns the absolute value of provided value.
- Code: -20 | integerType
Input: -20
Output: NEGATIVE
- Code: 0 | integerType
Input: 0
Output: NIL
- Code: 20 | integerType
Input: 20
Output: POSITIVE
#This pipe returns the nature of provided value.
- Code: 25 | ordinal
Input: 25
Output: 25th
- Code: 33 | ordinal
Input: 33
Output: 33rd
#This pipe returns the ordinal value of provided value.
Boolean returning pipes:
Below boolean returning pipes are available as a part of this library:
- isArray
- isBinary
- isDefined
- isEqual
- isFunction
- isIdentical
- isNil
- isNull
- isNumber
- isObject
- isString
- isTruthy
- isUndefined
Examples:
- Code: ['45', 97] | isArray
Input: ['45', 97]
Output: true
- Code: '45a' | isArray
Input: 45a
Output: false
#Returns a boolean showing if input is Array or not.
- Code: ['45', 97] | isBinary
Input: ['45', 97]
Output: false
- Code: 11000110 | isBinary
Input: 11000110
Output: true
#Returns a boolean showing if input is Binary or not.
- Code: ['45', 97] | isDefined
Input: ['45', 97]
Output: true
- Code: null | isDefined
Input: null
Output: false
#Returns a boolean showing if input is Defined or not.
- Code: ['45', 97] | isEqual: 10
Input: ['45', 97]
Output: false
- Code: '10' | isEqual: 10
Input: 10
Output: true
#Returns a boolean showing if input is Equal to given data or not[Datatype ignored].
- Code: ['45', 97] | isFunction
Input: ['45', 97]
Output: false
- Code: filterFunction | isFunction
Input: filterFunction
Output: true
#Returns a boolean showing if input is Function or not.
- Code: 125 | isIdentical: '125'
Input: 125
Output: false
- Code: '125' | isIdentical: '125'
Input: '125'
Output: true
#Returns a boolean showing if input is strictly Equal to given data or not.
- Code: 125 | isNil
Input: 125
Output: false
- Code: '0' | isNil
Input: 0
Output: true
#Returns a boolean showing if input is Zero or not.
- Code: 125 | isNull
Input: 125
Output: false
- Code: null | isNull
Input: null
Output: true
#Returns a boolean showing if input is null or not.
- Code: 125 | isNumber
Input: 125
Output: true
- Code: '125' | isNumber
Input: '125'
Output: true
- Code: '125a' | isNumber
Input: '125a'
Output: false
#Returns a boolean showing if input is a number or not.
- Code: 125 | isObject
Input: 125
Output: false
- Code: {name: 'Adam', prof: 'Teacher'} | isObject
Input: {name: 'Adam', prof: 'Teacher'}
Output: true
#Returns a boolean showing if input is an object or not.
- Code: 125 | isString
Input: 125
Output: false
- Code: '125' | isString
Input: '125'
Output: true
#Returns a boolean showing if input is string or not.
- Code: true | isTruthy
Input: true
Output: true
- Code: '125' | isTruthy
Input: '125'
Output: false
#Returns a boolean showing if input is true or not.
- Code: undefined | isUndefined
Input: undefined
Output: true
- Code: '125' | isUndefined
Input: '125'
Output: false
#Returns a boolean showing if input is undefined or not.
Object related pipes:
Below object related pipes are available as a part of this library:
- keyArray
- toArray
- normaliseObjArray
- stringify
Examples:
- Code: ['45', 97] | keyArray
Input: ['45', 97]
Output: ["0","1"]
- Code: {name: 'Adam', prof: 'Teacher'} | keyArray
Input: {name: 'Adam', prof: 'Teacher'}
Output: ["name","prof"]
#Returns an Array of all the indexes of given Object/Array.
- Code: ['45', 97] | toArray
Input: ['45', 97]
Output: ["45",97]
- Code: {name: 'Adam', prof: 'Teacher'} | toArray
Input: {name: 'Adam', prof: 'Teacher'}
Output: ["Adam","Teacher"]
#Returns an Array of all the values of given Object/Array.
- Code: [ {name: 'Adam', prof: 'Engineer'}, {name: 'Brian', prof: 'Teacher', age: 25}, {name: 'Chloe', age: 30} ] | normaliseObjArray: {name: 'Raj', prof: 'Programmer', age: 24}
Input: [ {name: 'Adam', prof: 'Engineer'}, {name: 'Brian', prof: 'Teacher', age: 25}, {name: 'Chloe', age: 30} ]
Output: [{"name":"Adam","prof":"Engineer","age":24},{"name":"Brian","prof":"Teacher","age":25},{"name":"Chloe","age":30,"prof":"Programmer"}]
#Returns an Array with added default properties of given Object/Array.
- Code: {name: 'Adam', prof: 'Teacher'} | stringify
Input: {name: 'Adam', prof: 'Teacher'}
Output: {"name":"Adam","prof":"Teacher"} - WITH STRINGIFY
Output: [object Object] - WITHOUT STRINGIFY
#Returns an Renderable template Object.