1.3.3 • Published 4 years ago
sagittarius-core v1.3.3
Getting started.
- Install:
npm i sagittarius-core
const { random, isEmpty } = require('sagittarius-core')
// Or install needed utils separately
// const random = require('sagittarius-random')
// check if argument is empty
console.log(isEmpty({})) // true
// get a random nr
console.log(random(12, 21))
Or use via cdn:
<!--index.html-->
<script src="https://cdn.jsdelivr.net/npm/sagittarius-core@latest/build/index.js"></script>
<script>
// check if argument is empty
console.log(sagittarius.isEmpty({ a: 21 })) // false
// get a random nr
console.log(sagittarius.random(12, 21))
</script>
See more utils in description below
Data generation
- random: Random number generation from range
- uniqueId: Generates a unique ID. If
prefix
is given, the ID is appended to it. - range: Creates an array of numbers (positive and/or negative) progressing from start up to, but not including, end. A step of -1 is used if a negative start is specified without an end or step. If end is not specified, it's set to start with start then set to 0.
Data validation
- isEmpty: Check if provided argument is empty
- has: Checks if path is a direct property of provided argument.
Data transformation
- toNumber: Transform provided argument to number
- toPath: Transform provided argument to a property path array
Data sorting
- uniq: Filter and return uniq values from an array
- get: Gets the value at path of provided argument. If the resolved value is undefined, the defaultValue is returned in its place.
- difference: Compare 2 arguments and return the difference. The order and references of result values are determined by the first argument.
Data manipulation
- debounce: Creates a debounced function that delays invoking
func
until afterwait
milliseconds have elapsed since the last time the debounced function was invoked. - set: Sets the value at path of provided argument. If a portion of path doesn't exist, it's created. Return true or false if value is set with success.
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
Or you can sponsor via Open Collective
Author
@Gherciu/sagittarius © GHERCIU, Released under the MIT License. Authored and maintained by GHERCIU with help from contributors (list).
If you like this repository star⭐ and watch👀 on GitHub
1.3.3
4 years ago
1.3.2
4 years ago
1.3.1
4 years ago
1.3.0
4 years ago
1.2.1
4 years ago
1.2.0
4 years ago
1.1.10
4 years ago
1.1.9
4 years ago
1.1.8
4 years ago
1.1.7
4 years ago
1.1.6
4 years ago
1.1.5
5 years ago
1.1.4
5 years ago
1.1.3
5 years ago
1.1.2
5 years ago
1.1.1
5 years ago
1.1.0
5 years ago
1.0.6
5 years ago
1.0.5
5 years ago
1.0.4
5 years ago
1.0.3
5 years ago
1.0.2
5 years ago
1.0.1
5 years ago