env
.env file loader and typed environment helper for OSL
import "osl/env"Methods
env.home()→stringenv.cwd()→stringenv.file(path)→envFileenv.read(path)→envFileenv.parse(text)→envFileenv.from(values)→envFileenv.stringify(values)→stringenv.load(...paths)→booleanenv.overload(...paths)→booleanenv.local()→booleanenv.localOverload()→booleanenv.get(key)→stringenv.getDefault(key, def)→stringenv.value(key)→OSLenvValueenv.getInt(key, def)→numberenv.getFloat(key, def)→numberenv.getBool(key, def)→booleanenv.has(key)→booleanenv.set(key, value)→booleanenv.unset(key)→booleanenv.require(key)→stringenv.required(...keys)→booleanenv.missing(...keys)→arrayenv.all()→objectenv.keys()→arrayenv.expand(value)→stringenv.mode()→stringenv.isDev()→booleanenv.isProd()→booleanenv.isTest()→boolean
Returned object: envValue
envValueReturned by env methods; call these on the value you get back.
envValue.key()→stringenvValue.exists()→booleanenvValue.string()→stringenvValue.fallback(def)→stringenvValue.int(def)→numberenvValue.float(def)→numberenvValue.bool(def)→boolean
Returned object: envFile
envFileReturned by env methods; call these on the value you get back.
envFile.path()→stringenvFile.setPath(path)→envFileenvFile.loaded()→booleanenvFile.read()→booleanenvFile.load()→booleanenvFile.overload()→booleanenvFile.apply()→booleanenvFile.applyOverload()→booleanenvFile.save()→booleanenvFile.text()→stringenvFile.all()→objectenvFile.keys()→arrayenvFile.has(key)→booleanenvFile.value(key)→OSLenvValueenvFile.get(key)→stringenvFile.getDefault(key, def)→stringenvFile.getInt(key, def)→numberenvFile.getFloat(key, def)→numberenvFile.getBool(key, def)→booleanenvFile.set(key, value)→envFileenvFile.unset(key)→envFileenvFile.clear()→envFileenvFile.merge(values)→envFileenvFile.expand(key)→string
Complete API reference
env
envenv.home()
string
Runs the home operation.
env.cwd()
string
Runs the cwd operation.
env.file(path: string)
*envFile
Runs the file operation.
env.read(path: string)
*envFile
Runs the read operation.
env.parse(text: string)
*envFile
Parses input data.
env.from(values: object)
*envFile
Runs the from operation.
env.stringify(values: object)
string
Serialises a value to text.
env.load(...paths: string)
boolean
Runs the load operation.
env.overload(...paths: string)
boolean
Runs the overload operation.
env.local()
boolean
Runs the local operation.
env.localOverload()
boolean
Runs the local overload operation.
env.get(key: string)
string
Returns a value.
env.getDefault(key: string, def: string)
string
Returns default.
env.value(key: string)
envValue
Runs the value operation.
env.getInt(key: string, def: number)
number
Returns int.
env.getFloat(key: string, def: number)
number
Returns float.
env.getBool(key: string, def: boolean)
boolean
Returns bool.
env.has(key: string)
boolean
Reports whether the value exists.
env.set(key: string, value: any)
boolean
Sets a value.
env.unset(key: string)
boolean
Runs the unset operation.
env.require(key: string)
string
Runs the require operation.
env.required(...keys: string)
boolean
Runs the required operation.
env.missing(...keys: string)
array
Runs the missing operation.
env.all()
object
Runs the all operation.
env.keys()
array
Returns all keys.
env.expand(value: string)
string
Runs the expand operation.
env.mode()
string
Runs the mode operation.
env.isDev()
boolean
Reports whether dev.
env.isProd()
boolean
Reports whether prod.
env.isTest()
boolean
Reports whether test.
envFile values
envFile valuesMethods available on envFile values returned by this package or constructed by the language.
value.OSLensure()
void
Runs the oslensure operation.
value.path()
string
Runs the path operation.
value.setPath(path: string)
*envFile
Sets path.
value.loaded()
boolean
Runs the loaded operation.
value.read()
boolean
Runs the read operation.
value.load()
boolean
Runs the load operation.
value.overload()
boolean
Runs the overload operation.
value.apply()
boolean
Runs the apply operation.
value.applyOverload()
boolean
Runs the apply overload operation.
value.save()
boolean
Runs the save operation.
value.text()
string
Runs the text operation.
value.all()
object
Runs the all operation.
value.keys()
array
Returns all keys.
value.has(key: string)
boolean
Reports whether the value exists.
value.value(key: string)
envValue
Runs the value operation.
value.get(key: string)
string
Returns a value.
value.getDefault(key: string, def: string)
string
Returns default.
value.getInt(key: string, def: number)
number
Returns int.
value.getFloat(key: string, def: number)
number
Returns float.
value.getBool(key: string, def: boolean)
boolean
Returns bool.
value.set(key: string, value: any)
*envFile
Sets a value.
value.unset(key: string)
*envFile
Runs the unset operation.
value.clear()
*envFile
Clears all stored values.
value.merge(values: object)
*envFile
Runs the merge operation.
value.expand(key: string)
string
Runs the expand operation.
envValue values
envValue valuesMethods available on envValue values returned by this package or constructed by the language.
value.key()
string
Runs the key operation.
value.exists()
boolean
Reports whether the value or resource exists.
value.string()
string
Runs the string operation.
value.fallback(def: string)
string
Runs the fallback operation.
value.int(def: number)
number
Runs the int operation.
value.float(def: number)
number
Runs the float operation.
value.bool(def: boolean)
boolean
Runs the bool operation.
Notes
Standard-library imports accept both
import "osl/env"andimport "env".Return values such as
arrayandobjectare regular OSL values unless a returned object section says otherwise.
Last updated