Check examples directory examples
yarn add @muft/dot
# or
npm install @muft/dot --saveTest if variable is object or not @Returns Boolan (TRUE | FALSE)
import { isObj } from '@muft/dot'
isObj({foo: 'bar'});
//=> true
isObj([1, 2, 3]);
//=> false
isObj('foo');
//=> falseTest if object is undefined or empty @Returns Boolan (TRUE | FALSE)
import { isEmpty } from '@muft/dot'
isEmpty({foo: 'bar'});
//=> false
isEmpty(undefined);
//=> true
isEmpty({});
//=> trueConvert dot notation to the array of strings @Returns string[]
import { getPathSegments } from '@muft/dot'
getPathSegments('app.name');
//=> ['app', 'name']Parse object values out of dot notation string if value not find the it will returns defalut value. @Returns any
import { get } from '@muft/dot'
const student = {
name: 'Test',
class: {
rank: 1
}
}
get(student, 'name');
//=> Test
get(student, 'class.rank');
//=> 1
get(student, 'class.test', 'defalut');
//=> default
get(student, 'class.test');
//=> nullParse object values out of string array if value not find the it will returns defalut value. @Returns any
import { getArrayValue } from '@muft/dot'
const student = {
name: 'Test',
class: {
rank: 1
}
}
getArrayValue(student, ['name']);
//=> Test
getArrayValue(student, ['class', 'rank']);
//=> 1
getArrayValue(student, ['class', 'test'], 'defalut');
//=> default
getArrayValue(student, ['class', 'test']);
//=> nullIf you would like to contribute to the project, please fork it and send us a pull request. Please add tests for any new features or bug fixes.
- Author - Aman Khanakia
- Website - https://khanakia.com
This Project is MIT licensed.