@schmiedmayerlab/grove-firebase-utils
v0.1.1
Published
Utility functions for Firebase projects
Maintainers
Readme
Grove Firebase Utils
A collection of utility functions for Firebase projects, for TypeScript applications. This package provides core utilities used by other Grove Firebase packages.
Installation
npm install @schmiedmayerlab/grove-firebase-utilsFeatures
- Schema Converters: Type-safe data conversion with Zod
- Localization: Easily handle multi-language text with fallbacks
- Array Helpers: Functions for working with arrays (average, median, percentile, etc.)
- Date Utilities: Simple date manipulation functions
- Lazy Loading: Generic lazy initialization pattern
Usage Examples
Schema Converter
import { SchemaConverter } from '@schmiedmayerlab/grove-firebase-utils'
import { z } from 'zod'
const userSchema = z.object({
name: z.string(),
email: z.email(),
age: z.number().optional(),
})
const userConverter = new SchemaConverter({
schema: userSchema,
encode: (user) => ({
name: user.name,
email: user.email,
age: user.age,
}),
})Localized Text
import { LocalizedText } from '@schmiedmayerlab/grove-firebase-utils'
const greeting = new LocalizedText({
en: 'Hello',
es: 'Hola',
fr: 'Bonjour',
})
console.log(greeting.localize('fr')) // 'Bonjour'
console.log(greeting.localize('de', 'en')) // 'Hello' (fallback)License
This project is licensed under the MIT License. See Licenses for more information.
Contributors
This project is developed as part of the Schmiedmayer Lab at Stanford University. See the repository's CONTRIBUTORS.md.
