This is a Node.js module available through the npm registry. Before installing, it´s necesary to install Node.js to install use the npm install command: ``` $ npm install sbdt ``` ## Functions ### There are many functions that you can use with this
npm install sbdt
$ npm install sbdt
`
Functions
$3
1. arrayToCSV
2. castToBoolean
3. combineObjects
4. csvToArray
5. isArray
6. isEmptyArray
7. isEmptyObject
8. isFunction
9. isNotArray
10. isNotEmptyArray
11. isNotEmptyObject
12. isNotFunction
13. isNotNull
14. isNotObject
15. isNotPromise
16. isNull
17. isObject
18. isPromise
19. safeExtract
20. safeIsNotNull
21. safeIsNull
22. isBigInt
23. isBoolean
24. isDate
25. isNotBigInt
26. isNotBoolean
27. isNotDate
28. isNotNumber
29. isNotString
30. isNotSymbol
31. isNumber
32. isString
33. isSymbol
34. toArray
35. toBoolean
36. toDate
37. toLowerCase
38. toNumber
39. toString
40. toTimestamp
41. toTitleCase
42. toUpperCase
43. getRandomString
44. getRandomNumberString
45. isUndefined
46. isNotUndefined
Arrat To CSV
arrayToCSV() Receives an array of either numbers or texts and returns a csv text
`JavaScript
arrayToCSV([1,2,3,4]); // 1, 2, 3, 4
arrayToCSV(['Hello', 'World']); // Hello, World
`
Cast To Boolean
castToBoolean() cast a variable to boolean
`JavaScript
castToBoolean("true"); // true
castToBoolean("1"); // true
castToBoolean(1); // true
castToBoolean("false"); // false
castToBoolean("0"); // false
castToBoolean(0); // false
castToBoolean({}); // false
castToBoolean(undefined); // false
`
Combine Objects
combineObjects() Receives a list or lists of objects and combines them
`JavaScript
combineObjects([{a:1,b:2,c:3},{d:4,e:5,f:6}]); // { a: 1, b: 2, c: 3, d: 4, e: 5, f: 6 }
combineObjects([{a:11,b:12,c:13},{c:14,d:15,e:16}]); // { a: 11, b: 12, c: 14, d: 15, e: 16 }
`
CSV To Array
csvToArray() It convert a csv to an array
`JavaScript
csvToArray('1,2,3,4'); // [ '1', '2', '3', '4' ]
csvToArray('Hello,World'); // [ 'Hello', 'World' ]
csvToArray('CSV,|ARRAY','|') // [ 'CSV,', 'ARRAY' ]
`
Is Array
isArray() Evaluate if a value is an array
`JavaScript
isArray([1,2,3,4]); // true
isArray([]); // true
isArray({}); // false
isArray(1); // false
`
Is Empty Array
isEmptyArray() It validate if a variable is an empty array
`JavaScript
isEmptyArray([]); // true
isEmptyArray([1,2,3]); // false
`
Is Empty Object
isEmptyObject() it Verify if a variable is an empty object
`JavaScript
isEmptyObject({}); // true
isEmptyObject({a:1}); // false
`
Is Function
isFunction() It validate if a variable is a function
`JavaScript
isFunction(()=>null); // true
isFunction(1); // false
`
Is Not Array
isNotArray() Evaluate if a value is not an array
`JavaScript
isNotArray([]); // false
isNotArray(1); // true
`
Is Not Empty Array
isNotEmptyArray() It validate if a variable isn't an empty array
`JavaScript
isNotEmptyArray([]); // false
isNotEmptyArray([1,2,3]); // true
`
Is Not Empty Object
isNotEmptyObject() It Verify if a variable is not an empty object
`JavaScript
isNotEmptyObject({}); // false
isNotEmptyObject({a:1}); // true
`
Is Not Function
isNotFunction() It validate if a variable isn't a function
`JavaScript
isNotFunction(()=>null); // false
isNotFunction(1); // true
`
Is Not Null
isNotNull() Validates if a variable is not null or undefined
`JavaScript
isNotNull(undefined); // false
isNotNull(null); // false
isNotNull(1); // true
`
Is Not Object
isNotObject() It validate if a variable isn't an object
`JavaScript
isNotObject({}); // true
isNotObject([]); // false
`
Is Not Promise
isNotPromise() it validates if a variable is not a promise
`JavaScript
isNotPromise(new Promise((resolve)=>resolve(1))); // false
isNotPromise([]); // true
`
Is Null
isNull() Validates if a variable is null or undefined
`JavaScript
isNull(undefined); // true
isNull(null); // true
isNull(1); // true
`
Is Object
isObject() It validate if a variable is an object
`JavaScript
isObject({}); // true
isObject([]); // false
`
Is Promise
isPromise() It validates if a variable is a promise
`JavaScript
isPromise(new Promise((resolve)=>resolve(1))); // true
isPromise([]); // false
`
Safe Extract
safeExtract() It extract at attribute from a variable if it exists in some "level", it´s a great way to extract if a key exists without throw errors
`JavaScript
const extractor = {a:{parameter: 1}};
safeExtract(extractor, ['a']); // { parameter: 1 }
safeExtract(extractor, ['b']); // undefined
safeExtract(extractor, ['a', 'parameter']); // 1
safeExtract(extractor, ['b', 'parameter']); // undefined
`
Safe Is Not Null
safeIsNotNull() It validate if a variable (object) contains an attribute, it can be in differents "levels"
`JavaScript
const extractor = {a:{parameter: 1}};
safeIsNotNull(extractor, ['a']); // true
safeIsNotNull(extractor, ['b']); // false
safeIsNotNull(extractor, ['a', 'parameter']); // true
safeIsNotNull(extractor, ['b', 'parameter']); // false
`
Safe Is Null
safeIsNull() It validate if a variable (object) not contains an attribute, it can be in differents "levels"
`JavaScript
const extractor = {a:{parameter: 1}};
safeIsNull(extractor, ['a']); // false
safeIsNull(extractor, ['b']); // true
safeExtract(extractor, ['a', 'parameter']); // false
safeExtract(extractor, ['b', 'parameter']); // true
`
Is Big Int
isBigInt() It let you know if a variable is a BigInt
`JavaScript
isBigInt(1n); // true
isBigInt(1); // false
`
Is Boolean
isBoolean() It help you to know if a variable is a boolean
`JavaScript
isBoolean(true); // true
isBoolean(1); // false
isBoolean(false); // true
isBoolean(0); // false
`
Is Date
isDate() It help you to know if a variable is a Date \( Date class \).
`JavaScript
isDate(new Date()); // true
isDate(1); // false
`
Is Not Big Int
isNotBigInt() It let you know if a variable is not a BigInt.
`JavaScript
isBigInt(1n); // false
isBigInt(1); // true
`
Is Not Boolean
isNotBoolean() It help you to know if a variable isn't a boolean.
`JavaScript
isBoolean(true); // false
isBoolean(1); // true
isBoolean(false); // false
isBoolean(0); // true
`
Is Not Date
isNotDate() It help you to know if a variable isn't a Date \( Date class \)
`JavaScript
isDate(new Date()); // false
isDate(1); // true
`
Is Not Number
isNotNumber() Help you to know if a variable isn't a number
`JavaScript
isNotNumber(1); // false
isNotNumber('a'); // true
`
Is Not String
isNotString() It help you to know if a variable isn't a String
`JavaScript
isNotNumber(1); // true
isNotNumber('a'); // false
`
Is Not Symbol
isNotSymbol() Help you to know if a variable isn't a symbol
`JavaScript
isNotSymbol(Symbol('id')); // false
isNotSymbol('id'); // true
`
Is Number
isNumber() Help you to know if a variable is a number
`JavaScript
isNumber(1); // true
isNumber('1'); // false
`
Is String
isString() It help you to know if a variable is a String
`JavaScript
isString(1); // false
isString('1'); // true
`
Is Symbol
isSymbol() Help you to know if a variable is a symbol
`JavaScript
isSymbol(Symbol('id')); // false
isSymbol('id'); // true
`
To Array
toArray() Help you to get a array from any type of variable if the variable is an array already it will return the same array
`JavaScript
toArray(1); // [ 1 ]
toArray('1'); // [ '1' ]
toArray(['1', '2']); // [ '1', '2' ]
toArray({a:1}); // [ { a: 1 } ]
toArray(undefined); // []
`
To Boolean
toBoolean() It cast a variable to boolean
`JavaScript
toBoolean("true"); // true
toBoolean("1"); // true
toBoolean(1); // true
toBoolean("false"); // false
toBoolean("0"); // false
toBoolean(0); // false
toBoolean({}); // false
toBoolean(undefined); // false
`
To Date
toDate() Help you to get a Date variable form a string variable
`JavaScript
toDate('07-30-2000'); // 964933200000
`
To Low Case
toLowerCase() Help you to convert a string or variable to a lower case string
`JavaScript
toLowerCase('Hello World'); // hello world
toLowerCase('HELLO WORLD'); // hello world
`
To Number
toNumber() Help you to cast a variable to a Number
`JavaScript
toNumber('1231'); // 1231
toNumber('32.12'); // 32.12
toNumber(1n); // 1
toNumber(4); // 4
`
To String
toString() Cast an any variable to a String
`JavaScript
toString('Hello World'); // "Hello World"
toString(321); // "321"
toString({a:1}); // "{\"a\":1}"
toString([1,2,3]); // "[1,2,3]"
`
To Timestamp
toTimestamp() Help you to cast a variable to a Timestamp number, it can be Date or String
`JavaScript
toTimestamp(new Date()); // 1684000479.627
toTimestamp('01-01-2020'); // 1577858400
`
To Title Case
toTitleCase() Help you to cast a variable or a String to a Title case
`JavaScript
toTitleCase('hello world'); // Hello World
toTitleCase('HELLO WORLD'); // Hello World
`
To Upper Case
toUpperCase() Help you to cast a variable to a String
`JavaScript
toUpperCase('hello world'); // HELLO WORLD
toUpperCase('Hello World'); // HELLO WORLD
`
Get Random String
getRandomString() Help you to get a random string with numbers
`JavaScript
getRandomString(4); // MJWh
getRandomString(10); // ehQNovk4cI
`
Get Random Number String
getRandomNumberString() Help you to get a random string of numbers
`JavaScript
getRandomString(4); // 4761
getRandomString(10); // 8960631952
`
Is Undefined
isUndefined() Validates if a variable is undefined
`JavaScript
isUndefined(4); // false
isUndefined(null); // false
isUndefined(undefined); // true
`
Is Not Undefined
isNotUndefined() Validates if a variable is not undefined
`JavaScript
isNotUndefined(4); // true
isNotUndefined(null); // true
isNotUndefined(undefined); // false
``