
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
mimic-tree is a Node.js library for creating dynamic data trees that mimic the structure of source data. It reproduces the original folder paths and file structures like JSON or YAML with different values, maintaining the integrity of the original structu
mimic-tree is a Node.js package designed to convert values in JSON and YAML files within a specified directory, outputting the transformed content to a new directory while preserving the original structure. This can be particularly useful, for instance, when you want to batch translate language resource data.
npm install mimic-tree
Import the mimicTree function and use it with the necessary options as shown below:
import { mimicTree } from 'mimic-tree'
async function main() {
await mimicTree({
src: 'basic',
cwd: __dirname,
dist: 'basic-result',
extensions: ['json', 'yaml'],
convert: (v: string | number | null) => v /* ... convert value ... */
})
}
['json']
.
If you want to target both JSON and YAML files, specify ['json', 'yaml']
and run npm install yarn
.If your language resource data is managed in JSON or YAML formats, you can use this package to apply translation APIs or custom functions and output the translated data into a new directory.
For instance, when combined with a translation API like Google Translate, you could set it up for batch translations as shown:
import { mimicTree } from 'mimic-tree'
import { resolve } from 'path'
import { translate } from 'your-translate-api'
/**
* @params fromLocale (e.g. 'en')
* @params toLocale (e.g. 'ja')
*/
export async function translate(fromLocale: string, toLocale: string) {
await mimicTree({
src: fromLocale,
cwd: resolve(__dirname, 'locales'),
dist: toLocale,
extensions: ['json', 'yaml'],
convert: async (v) =>
typeof v === 'string' ? await translate(v, fromLocale, toLocale) : v
})
}
see CONTRIBUTING.md
FAQs
mimic-tree is a Node.js library for creating dynamic data trees that mimic the structure of source data. It reproduces the original folder paths and file structures like JSON or YAML with different values, maintaining the integrity of the original structu
We found that mimic-tree demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.