@robinpath/glob
0.1.1Node.jsPublicFile pattern matching: find files by glob patterns, test matches, expand braces
Glob
File pattern matching: find files by glob patterns, test matches, expand braces
Package: @robinpath/glob | Category: Utility | Type: Utility
Authentication
No authentication required. All functions are available immediately.
Use Cases
Use the glob module when you need to:
- Find files matching a glob pattern -- Use
glob.matchto perform this operation - Test if a path matches a glob pattern -- Use
glob.isMatchto perform this operation - Convert a glob pattern to a regex string -- Use
glob.toRegexto perform this operation - Expand brace pattern into array -- Use
glob.expandto perform this operation - Extract non-glob base directory from pattern -- Use
glob.baseto perform this operation
Quick Reference
| Function | Description | Returns |
|---|---|---|
match | Find files matching a glob pattern | Array of matching file paths |
isMatch | Test if a path matches a glob pattern | True if matches |
toRegex | Convert a glob pattern to a regex string | Regex source string |
expand | Expand brace pattern into array | Array of expanded strings |
base | Extract non-glob base directory from pattern | Base directory path |
hasMagic | Check if string contains glob characters | True if contains glob chars |
Functions
match
Find files matching a glob pattern
Module: glob | Returns: array -- Array of matching file paths
glob.match "src/**/*.ts"
| Parameter | Type | Required | Description |
|---|---|---|---|
pattern | string | Yes | Glob pattern (e.g. **/*.ts) |
cwd | string | No | Working directory (default: .) |
isMatch
Test if a path matches a glob pattern
Module: glob | Returns: boolean -- True if matches
glob.isMatch "src/index.ts" "**/*.ts"
| Parameter | Type | Required | Description |
|---|---|---|---|
filePath | string | Yes | File path to test |
pattern | string | Yes | Glob pattern |
toRegex
Convert a glob pattern to a regex string
Module: glob | Returns: string -- Regex source string
glob.toRegex "*.ts"
| Parameter | Type | Required | Description |
|---|---|---|---|
pattern | string | Yes | Glob pattern |
expand
Expand brace pattern into array
Module: glob | Returns: array -- Array of expanded strings
glob.expand "file.{ts,js}"
| Parameter | Type | Required | Description |
|---|---|---|---|
pattern | string | Yes | Pattern with braces (e.g. {a,b,c}) |
base
Extract non-glob base directory from pattern
Module: glob | Returns: string -- Base directory path
glob.base "src/**/*.ts"
| Parameter | Type | Required | Description |
|---|---|---|---|
pattern | string | Yes | Glob pattern |
hasMagic
Check if string contains glob characters
Module: glob | Returns: boolean -- True if contains glob chars
glob.hasMagic "*.ts"
| Parameter | Type | Required | Description |
|---|---|---|---|
str | string | Yes | String to check |
Error Handling
All functions throw on failure. Common errors:
| Error | Cause |
|---|---|
| (standard errors) | Check function parameters and authentication |
@desc "Match and validate result"
do
set $result as glob.match "src/**/*.ts"
if $result != null
print "Success"
else
print "No result"
end
enddo
Recipes
1. Multi-step Glob workflow
Chain multiple glob operations together.
@desc "Match, is match, and more"
do
set $r_match as glob.match "src/**/*.ts"
set $r_isMatch as glob.isMatch "src/index.ts" "**/*.ts"
set $r_toRegex as glob.toRegex "*.ts"
print "All operations complete"
enddo
2. Safe match with validation
Check results before proceeding.
@desc "Match and validate result"
do
set $result as glob.match "src/**/*.ts"
if $result != null
print "Success: " + $result
else
print "Operation returned no data"
end
enddo
Related Modules
- json -- JSON module for complementary functionality
Versions (1)
| Version | Tag | Published |
|---|---|---|
| 0.1.1 | latest | 1 months ago |
Related Modules
@robinpathv0.1.4
SMTP email sending and address parsing for RobinPath
hash
JS@robinpathv0.1.3
Cryptographic hashing utilities: MD5, SHA family, HMAC, CRC32, file hashing, UUID v5 generation, secure random bytes, and content fingerprinting
csv
JS@robinpathv0.1.2
Parse and stringify CSV data
apollo
JS@robinpathv0.1.2
Apollo module for RobinPath.
$ robinpath add @robinpath/glob
