All Projects → JakubMifek → SelectTransform

JakubMifek / SelectTransform

Licence: Apache-2.0 license
This project is based upon https://github.com/SelectTransform/st.js but differs in implementation, functionality and robustness.

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to SelectTransform

Beehive
🐝 BeeHive is a solution for iOS Application module programs, it absorbed the Spring Framework API service concept to avoid coupling between modules.
Stars: ✭ 4,117 (+24117.65%)
Mutual labels:  modular, module
Komada
Komada: Croatian for `pieces`, is a modular bot system including reloading modules and easy to use custom commands.
Stars: ✭ 67 (+294.12%)
Mutual labels:  modular, module
Tinypart
TinyPart is an iOS modularization framework implemented by Ojective-C. It also supports URL-routing and inter-module communication. TinyPart是一个由Objective-C编写的面向协议的iOS模块化框架,同时它还支持URL路由和模块间通信机制。
Stars: ✭ 120 (+605.88%)
Mutual labels:  modular, module
FAVITES
FAVITES (FrAmework for VIral Transmission and Evolution Simulation)
Stars: ✭ 33 (+94.12%)
Mutual labels:  modular
Thread
type safe multi-threading made easier
Stars: ✭ 34 (+100%)
Mutual labels:  module
ark.db
Small and fast JSON database for Node and browser. 😋
Stars: ✭ 65 (+282.35%)
Mutual labels:  module
AITools
AI 常用脚本
Stars: ✭ 35 (+105.88%)
Mutual labels:  transform
nitroml
NitroML is a modular, portable, and scalable model-quality benchmarking framework for Machine Learning and Automated Machine Learning (AutoML) pipelines.
Stars: ✭ 40 (+135.29%)
Mutual labels:  modular
ui patterns
[NOTE] Development has moved to https://drupal.org/project/ui_patterns
Stars: ✭ 87 (+411.76%)
Mutual labels:  module
CodeIgniter-HMVC
CodeIgniter 3.1.10 with Modular Extensions - HMVC and Whoops Error Handling Framework 2.5.0
Stars: ✭ 30 (+76.47%)
Mutual labels:  modular
StartupModules
Startup modules for ASP.NET Core.
Stars: ✭ 33 (+94.12%)
Mutual labels:  modular
fylgja
The modular highly customisable CSS framework. Powered by CSS Components, Utilities and Props for building your Web UI.
Stars: ✭ 65 (+282.35%)
Mutual labels:  modular
WebinoImageThumb
✂️ Webino™ Image thumbnailer for Zend Framework [LTS] http://webino.github.io/WebinoImageThumb
Stars: ✭ 40 (+135.29%)
Mutual labels:  module
ReDe
A Redis dehydrator module
Stars: ✭ 63 (+270.59%)
Mutual labels:  module
nuxt-brotli
Nuxt.js module which compresses assets with Brotli compression algorithm using `iltorb` library for serving it with `ngx_brotli`
Stars: ✭ 19 (+11.76%)
Mutual labels:  module
ProtocolServiceKit
iOS组件通信中间件(Protocol Service),Adapter Swift/Objective-C
Stars: ✭ 139 (+717.65%)
Mutual labels:  module
puppetlabs-dism
No description or website provided.
Stars: ✭ 19 (+11.76%)
Mutual labels:  module
ts-sfc-plugin
A plugin for optimizing stateless component of React (tsx)
Stars: ✭ 29 (+70.59%)
Mutual labels:  transform
react-watermark-module
React水印组件,支持图片水印,文字水印。
Stars: ✭ 31 (+82.35%)
Mutual labels:  module
Transform
Base Monogame objects for managing relative transforms.
Stars: ✭ 19 (+11.76%)
Mutual labels:  transform

SelectTransform

This project is based upon https://github.com/SelectTransform/st.js but differs in implementation, functionality and robustness.

Description

SelectTransform is a module that eases transformation of JS objects using JSON template and JS input data object.

JSON template may contain special readable notation describing how to transform data objects.

Installation

npm i selecttransform

Questions?

This package has deviated a bit from the original implementation and has numerous additional features. If you would like to contribute, join the development, help us maintain the repository or just have some questions about the usage, reach out to us on our community server: https://discord.gg/eNVm2N24

Example Usage

JavaScript

const ST = require('selecttransform').SelectTransform;

const st = new ST();

const data = {
  name: 'Jakub',
  friends: [
    {
      name: 'Michal',
    },
  ],
};

const template = {
  name: '{{ name }}',
  friends: {
    '{{ #each friends }}': {
      index: '{{ $index }}',
      name: '{{ name }}',
    },
  },
};

// Or you can use transformSync
st.transform(template, data).then(console.log);

// Result:
/**
 * {
 *   "name": "Jakub",
 *   "friends": [
 *     {
 *       "index": 0,
 *       "name": "Michal"
 *     },
 *   ],
 * }
 */

TypeScript

import { SelectTrasnform as ST } from 'selecttransform';

const st = new ST();

const data = {
  name: 'Jakub',
  friends: [
    {
      name: 'Michal',
    },
  ],
};

const template = {
  name: '{{ name }}',
  friends: {
    '{{ #each friends }}': {
      index: '{{ $index }}',
      name: '{{ name }}',
    },
  },
};

// Or you can use transform and promise-like structure
console.log(st.transformSync(template, data));

// Result:
/**
 * {
 *   "name": "Jakub",
 *   "friends": [
 *     {
 *       "index": 0,
 *       "name": "Michal"
 *     },
 *   ],
 * }
 */

For complete documentation see Wiki or tests.

Contributions

You are welcome to make a pull request to the repository which I will try to resolve as quickly as possible.

Mainly I'd expect you to want to extend functions available to you in templates. That is done using executors. Executors are separated into three categories:

  • Value executors - those are executors that are in place of any value in the template (eg. ternary executor: "name": "{{ #? path.to.name }}")
  • Key executors - those are executors that are in place of any key, usually represent a function which has name and parameters (eg. optional executor: "{{ #optional name }}": { ... })
  • Array executors - those are executors that are in place of an array (eg. conditional executor: [{ "{{ #if someCondition === true }}": "Correct" }, { "{{ #else }}": "Incorrect" }])

You can freely create new executor in each of these categories using provided templates and by adding them into corresponding index.ts files.

Alternatively, if you would like to make changes to Select or Transform classes I would gladly see to your requests or proposals.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].