<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Junbao Yang on Medium]]></title>
        <description><![CDATA[Stories by Junbao Yang on Medium]]></description>
        <link>https://medium.com/@joking.young?source=rss-cdcc2f2aa145------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Gqf8KXClO0NpSsHq.</url>
            <title>Stories by Junbao Yang on Medium</title>
            <link>https://medium.com/@joking.young?source=rss-cdcc2f2aa145------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 22:20:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@joking.young/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Enhance Your Log Reading Experience with Log Viewer: A Chrome Extension for Effortless JSON Log…]]></title>
            <link>https://towardsdev.com/enhance-your-log-reading-experience-with-log-viewer-a-chrome-extension-for-effortless-json-log-f5b12f958526?source=rss-cdcc2f2aa145------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5b12f958526</guid>
            <category><![CDATA[json]]></category>
            <category><![CDATA[visualization]]></category>
            <category><![CDATA[logging]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[chrome-extension]]></category>
            <dc:creator><![CDATA[Junbao Yang]]></dc:creator>
            <pubDate>Sun, 12 Jan 2025 02:41:41 GMT</pubDate>
            <atom:updated>2025-01-19T20:13:48.668Z</atom:updated>
            <content:encoded><![CDATA[<h3>Enhance Your Log Reading Experience with Log Viewer: A Chrome Extension for Effortless JSON Log Formatting</h3><p>With the growing popularity of containerization and the decreasing cost of log processing, JSON-formatted logs have become the preferred choice for many engineers. However, reading JSON logs can be challenging, especially when dealing with multi-line content like error stacks — even professional log viewers (like metabase, redash, datadog, etc) struggle to present them clearly.</p><p>To address this issue, I developed a Chrome extension called <strong>Log Viewer</strong> to enhance the log reading experience. You can download it from the <a href="https://chromewebstore.google.com/detail/log-viewer/lbnkfmnolbefifdccejjijdgdipnfaib"><strong>Chrome Web Store</strong></a> and explore the source code and full documentation on <a href="https://github.com/amos-project/log-viewer/"><strong>GitHub</strong></a>.</p><p>Using Log Viewer is incredibly simple:<br> Just hover your mouse over the log content you want to view and quickly press the <strong>V</strong> key twice. The log will automatically appear in a formatted and highlighted view, like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tKzs-VZWRQByI3ml" /></figure><p>As you can see, Log Viewer not only formats JSON logs but also optimizes the display of nested JSON strings and multi-line text, making it much easier to read and understand complex logs efficiently.</p><p>To exit the viewer, simply press the <strong>ESC</strong> key. By default, Log Viewer automatically detects and displays the content of the DOM element under your cursor. If you’re unsure about the exact DOM node containing the log, you can manually select the text and double-press <strong>V</strong> to view it.</p><p>Additionally, Log Viewer supports fetching log content directly from the clipboard by double-pressing the <strong>P</strong> key. It also handles ANSI-formatted logs and can format and highlight various source code formats such as HTML and JavaScript. You can find the full documentation on GitHub.</p><p>I invite you to try it out and share your feedback!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5b12f958526" width="1" height="1" alt=""><hr><p><a href="https://towardsdev.com/enhance-your-log-reading-experience-with-log-viewer-a-chrome-extension-for-effortless-json-log-f5b12f958526">Enhance Your Log Reading Experience with Log Viewer: A Chrome Extension for Effortless JSON Log…</a> was originally published in <a href="https://towardsdev.com/">Towards Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Three typescript plugins for working  better with styled-components, react-loadable…]]></title>
            <link>https://medium.com/@joking.young/three-typescript-plugins-for-working-better-with-styled-components-react-loadable-9ae00fba5656?source=rss-cdcc2f2aa145------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ae00fba5656</guid>
            <category><![CDATA[webpack]]></category>
            <category><![CDATA[react-loadable]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[styled-components]]></category>
            <dc:creator><![CDATA[Junbao Yang]]></dc:creator>
            <pubDate>Sat, 02 Nov 2019 10:29:25 GMT</pubDate>
            <atom:updated>2019-11-02T23:42:51.603Z</atom:updated>
            <content:encoded><![CDATA[<h3>Typescript plugin for working better with styled-components react-loadable and loadable-components.</h3><p>All three components provide the babel plugin to support js compilation, but none of them provide TypeScript related plugins. Although we can compile TypeScript with babel, there is no strict type checking. Therefore, in order to work better with TypeScript. I wrote the TypeScript transformers corresponding to these three components, which are used to complete the tasks completed by the corresponding babel components in the TypeScript compilation environment. They are:</p><ul><li><strong>For styled-components: </strong><a href="https://github.com/acrazing/typescript-styled-components-plugin"><strong>typescript-styled-components-plugin</strong></a><strong>.</strong></li></ul><p>helps you to transform code from:</p><pre>export const CastProps = [<br>  styled.div&lt;Props&gt;`<br>    display: block;<br>    background: ${() =&gt; &#39;black&#39;};<br>    color: white;<br>  `,<br>  styled(Base)&lt;Props&gt;`<br>    display: block;<br>    background: ${() =&gt; &#39;black&#39;};<br>    color: white;<br>  `,<br>];</pre><p>to:</p><pre>export const CastProps = [<br>  styled.div.withConfig({<br>    componentId: &#39;sc-2mrASk-6&#39;,<br>    displayName: &#39;CastProps&#39;,<br>  })`<br>    display: block;<br>    background: ${() =&gt; &#39;black&#39;};<br>    color: white;<br>  `,<br>  styled(Base).withConfig({<br>    componentId: &#39;sc-2mrASk-7&#39;,<br>    displayName: &#39;CastProps&#39;,<br>  })`<br>    display: block;<br>    background: ${() =&gt; &#39;black&#39;};<br>    color: white;<br>  `,<br>];</pre><ul><li><strong>For react-loadable: </strong><a href="https://github.com/acrazing/typescript-react-loadable-plugin"><strong>typescript-react-loadable-plugin</strong></a><strong>.</strong></li></ul><p>helps you to transform code from:</p><pre>import React from &#39;<a href="https://github.com/facebook/react">react</a>&#39;;<br>import Loadable from &#39;<a href="https://github.com/thejameskyle/react-loadable">react-loadable</a>&#39;;<br><br>export const LazyFoo = Loadable({<br>  loader: () =&gt; import(&#39;./input/Foo&#39;),<br>  loading: () =&gt; &lt;span&gt;Loading...&lt;/span&gt;,<br>});</pre><p>to:</p><pre>import React from &#39;<a href="https://github.com/facebook/react">react</a>&#39;;<br>import Loadable from &#39;<a href="https://github.com/thejameskyle/react-loadable">react-loadable</a>&#39;;<br>export const LazyFoo = Loadable({<br>  loading: () =&gt; React.createElement(&#39;span&#39;, null, &#39;Loading...&#39;),<br>  loader: () =&gt; import(&#39;./input/Foo&#39;),<br>  modules: [&#39;./input/Foo&#39;],<br>  webpack: () =&gt; [require.resolveWeak(&#39;./input/Foo&#39;)],<br>});</pre><ul><li><strong>For loadable-components: </strong><a href="https://github.com/acrazing/typescript-loadable-components-plugin"><strong>typescript-loadable-components-plugin</strong></a><strong>.</strong></li></ul><p>helps you to transform code from:</p><pre>import loadable from &#39;<a href="https://github.com/smooth-code/loadable-components">@loadable/component</a>&#39;;<br><br>export const LazyFoo = loadable(() =&gt; import(&#39;./input/AsyncDefaultComponent&#39;));</pre><p>to:</p><pre>import loadable from &#39;<a href="https://github.com/smooth-code/loadable-components">loadable-components</a>&#39;;<br><br>export const LazyFoo = loadable({<br>  chunkName() {<br>    return &#39;input-AsyncDefaultComponent&#39;;<br>  },<br>  isReady(props) {<br>    return (<br>      typeof __webpack_modules__ !== &#39;undefined&#39; &amp;&amp;<br>      Boolean(__webpack_modules__[this.resolve(props)])<br>    );<br>  },<br>  requireAsync: () =&gt;<br>    import(<br>      /* &quot;webpackChunkName&quot;:&quot;input-AsyncDefaultComponent&quot; */ &#39;./input/AsyncDefaultComponent&#39;<br>    ),<br>  requireSync(props) {<br>    return typeof &#39;__webpack_require__&#39; !== &#39;undefined&#39;<br>      ? __webpack_require__(this.resolve(props))<br>      : eval(&#39;module.require&#39;)(this.resolve(props));<br>  },<br>  resolve() {<br>    if (require.resolveWeak)<br>      return require.resolveWeak(<br>        /* &quot;webpackChunkName&quot;:&quot;input-AsyncDefaultComponent&quot; */ &#39;./input/AsyncDefaultComponent&#39;,<br>      );<br>    else<br>      return eval(&#39;require.resolve&#39;)(<br>        /* &quot;webpackChunkName&quot;:&quot;input-AsyncDefaultComponent&quot; */ &#39;./input/AsyncDefaultComponent&#39;,<br>      );<br>  },<br>});</pre><h3>Install</h3><p>You can use npm or yarn to install any one or more of them in your project:</p><pre>npm i -D typescript-styled-components-plugin<br>yarn add -D typescript-styled-components-plugin<br># ...</pre><h3>Usage</h3><p>All the there packages work with ttypescript or webpack</p><p>with ttypescript, you just need to add the package name to plugins in your tsconfig.json:</p><pre>{<br>  &quot;compilerOptions&quot;: {<br>    &quot;plugins&quot;: [<br>      {<br>        // the package name here<br>        &quot;transform&quot;: &quot;typescript-styled-components-plugin&quot;,<br>        // other options follow<br>      }<br>    ]<br>  }<br>}</pre><p>with webpack, you just need to add customTransformer for your loader:</p><pre>import createStyledComponentsTransformer from &#39;<a href="https://github.com/acrazing/typescript-styled-components-plugin">typescript-styled-components-plugin</a>&#39;;<br>export default {<br>  // ...<br>  module: {<br>    rules: [<br>      {<br>        test: /<strong>\.</strong>tsx?$/,<br>        loader: &#39;ts-loader&#39;, // or awesome-typescript-loader<br>        options: {<br>          getCustomTransformers: (program) =&gt; ({<br>            before: [<br>              createStyledComponentsTransformer(program, {<br>                setComponentId: true,<br>                setDisplayName: true,<br>                minify: true,<br>              }),<br>            ],<br>          }),<br>        },<br>      },<br>    ],<br>  },<br>};</pre><p>You can get more detailed documentation for the packages at the project’s GitHub homepage.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ae00fba5656" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[dpdm — A robust tool to find out circular dependencies in your JavaScript/TypeScript project]]></title>
            <link>https://medium.com/@joking.young/dpdm-a-robust-tool-to-find-out-circular-dependencies-in-your-javascript-typescript-project-6309a679e733?source=rss-cdcc2f2aa145------2</link>
            <guid isPermaLink="false">https://medium.com/p/6309a679e733</guid>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[command-line]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Junbao Yang]]></dc:creator>
            <pubDate>Thu, 18 Jul 2019 13:19:43 GMT</pubDate>
            <atom:updated>2019-07-18T13:19:43.306Z</atom:updated>
            <content:encoded><![CDATA[<h3>dpdm — A robust tool to find out circular dependencies in your JavaScript/TypeScript project</h3><p>When you are building large projects, if you are not particularly careful, circular references are inevitable. When your application is restarted during the development progress, suddenly nothing can be seen, and it will become overwhelming.<br>Although there is now a tool called madge that can be used to analyze dependencies, the results of the analysis are confusing, especially when analyzing JavaScript and TypeScript mixed projects, sometimes .ts files are inexplicably ignored. I tried to read the source code of the project, but the core logic relied on additional repositories. It seems that it is very troublesome to make improvements, so I wrote a project <a href="https://github.com/acrazing/dpdm">dpdm</a> to analyze the dependencies.<br>This project uses TypeScript as the abstract syntax tree (AST) parsing tool, so it can parse JavaScript and TypeScript very accurately. It also borrows some configuration methods of webpack, such as custom file extensions, module resolving, etc. It also provides a command line interface and a package interface for Node.js, so it is very convenient to use. Let me tell you how to use this repository!</p><h3>Install at first</h3><p>First you need to install this package, you can use npm or yarn. If you want to use it in the command line (recommended), you may need to install it globally. If you want to use it as an package, you only need to install it locally in your project.</p><pre># Install locally<br>npm i dpdm # or yarn add dpdm</pre><pre># Install globally<br>npm i -g dpdm # or yarn global add dpdm<br>dpdm --help</pre><h3>Command line usage</h3><p>dpdm provides a command line entry, which is called dpdm, you just need to use dpdm &lt;entrypoint&gt; to get the circular dependencies information. For example, if you has a project with the following directory tree:</p><pre>$ tree example<br>example<br>├── circular_a.js<br>├── circular_b.js<br>├── circular_c.js<br>├── circular_d.js<br>└── index.js</pre><pre>0 directories, 5 files</pre><p>And the contents of the files is:</p><pre>$ cat example/*</pre><pre># circular_a.js<br>require(&#39;./circular_b&#39;);</pre><pre># circular_b.js<br>require(&#39;./circular_c&#39;);</pre><pre># circular_c.js<br>require(&#39;./circular_d&#39;);</pre><pre>#circular_d.js<br>require(&#39;./circular_a&#39;);<br>require(&#39;./circular_b&#39;);</pre><pre># index.js<br>require(&#39;./circular_a&#39;);</pre><p>Then run dpdm ./example, you will get the following output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Plvw12fjuM-nMHCKwb4yrg.png" /></figure><p>You can see the example at <a href="https://github.com/acrazing/dpdm/tree/master/example">dpdm/example</a>.</p><p>Of course you can use dpdm --help to get the help message as following:</p><pre>$ dpdm --help<br>dpdm [&lt;options&gt;] entry...</pre><pre>Options:<br>  --version            Show version number  [boolean]<br>  --context            the context directory to shorten path, default is process.cwd()  [string]<br>  --extensions, --ext  comma separated extensions to resolve  [string] [default: &quot;.ts,.tsx,.mjs,.js,.jsx,.json&quot;]<br>  --include            included filenames regexp in string  [string] [default: &quot;\.[tj]sx?$&quot;]<br>  --exclude            excluded filenames regexp in string  [string] [default: &quot;/node_modules/&quot;]<br>  --output, -o         output json to file  [string]<br>  --tree               print tree to stdout  [boolean] [default: true]<br>  --circular           print circular to stdout  [boolean] [default: true]<br>  --warning            print warning to stdout  [boolean] [default: true]<br>  -h, --help           Show help  [boolean]</pre><h3>Package usage</h3><pre>import {<br>  parseDependencyTree,<br>  parseCircular,<br>  prettyCircular,<br>} from &#39;dpdm&#39;</pre><pre>const tree = await parseDependencyTree(<br>  &#39;./src/entries/**/*.*&#39;, // support glob or glob array<br>  {<br>    context: process.cwd(),<br>    extensions: [&#39;&#39;, &#39;.ts&#39;, &#39;.tsx&#39;, &#39;.mjs&#39;, &#39;.js&#39;, &#39;.jsx&#39;, &#39;.json&#39;],<br>    include: /\.[tj]sx?$/,<br>    exclude: /\/node_modules\//,<br>  }<br>);</pre><pre>const circulars = await parseCircular(tree)</pre><pre>console.log(prettyCircular(circulars))</pre><p>You can see the detailed document on GitHub: <a href="https://github.com/acrazing/dpdm#readme">https://github.com/acrazing/dpdm#readme</a>.</p><p>Enjoy your life~</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6309a679e733" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Magic constants for TypeScript like it in PHP]]></title>
            <link>https://medium.com/@joking.young/magic-constants-for-typescript-like-it-in-php-e7b4122476f9?source=rss-cdcc2f2aa145------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7b4122476f9</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[webpack]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Junbao Yang]]></dc:creator>
            <pubDate>Tue, 21 Aug 2018 16:28:58 GMT</pubDate>
            <atom:updated>2018-08-21T16:28:58.960Z</atom:updated>
            <content:encoded><![CDATA[<p>PHP contains some useful magic constants just like __CLASS__, __METHOD__, __FUNCTION__, etc. But it is not supported in native TypeScript. Now there is a plugin for TypeScript to do that, which is called as typescript-magic-variable-plugin</p><p>At first, you need to install the package in your TypeScript project:</p><pre>npm install -D typescript-magic-variable-plugin<br># or var yarn<br>yarn add -D typescript-magic-variable-plugin</pre><p>And then, update your tsconfig.json to invoke this plugin:</p><pre>{<br>  &quot;compilerOptions&quot;: {<br>    &quot;plugins&quot;: [<br>      { &quot;transform&quot;: &quot;typescript-magic-variable-plugin&quot; }<br>    ]<br>  },<br>  &quot;include&quot;: [<br>    // your files<br>    &quot;./node_modules/typescript-magic-variable-plugin/types/globals.d.ts&quot;<br>  ]<br>}</pre><p>Finally, you need to use ttypescript to compile your code with command line. Or add custom transformer for awesome-typescript-loader with webpack:</p><pre>const { createMagicVariableTransformer } = require(&#39;typescript-magic-variable-plugin&#39;)</pre><pre>// ...<br>rules: [<br>    {<br>        test: /<strong>\.</strong>tsx?$/,<br>        loader: &#39;awesome-typescript-loader&#39;,<br>        options: {<br>            // ... other loader&#39;s options<br>            getCustomTransformers: program =&gt; ({<br>                before: [<br>                   createMagicVariableTransformer(program, {})<br>                ]<br>            })<br>        }<br>    }<br>]</pre><p>This package support the following magic constants:</p><ul><li>__CLASS__</li><li>__METHOD__</li><li>__FUNCTION__</li><li>__NAMESPACE__</li><li>__DIR__</li><li>__FILE__</li></ul><p>and, could add displayName for react components.</p><p>You can get more detailed information on GitHub: <a href="https://github.com/acrazing/typescript-magic-variable-plugin">acrazing/typescript-magic-variable-plugin</a>.</p><p>Enjoy your life~</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7b4122476f9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[mobx-sync — a better library to persist your mobx stores]]></title>
            <link>https://medium.com/@joking.young/mobx-sync-a-better-library-to-persist-your-mobx-stores-1dafb8e5f00c?source=rss-cdcc2f2aa145------2</link>
            <guid isPermaLink="false">https://medium.com/p/1dafb8e5f00c</guid>
            <category><![CDATA[sap]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[storage]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[mobx]]></category>
            <dc:creator><![CDATA[Junbao Yang]]></dc:creator>
            <pubDate>Fri, 09 Feb 2018 17:49:32 GMT</pubDate>
            <atom:updated>2018-02-09T17:49:32.947Z</atom:updated>
            <content:encoded><![CDATA[<p>Some times we need to persist(serialize) mobx stores to storage automatically, and auto load it when the application is restarted. It is used for web applications to persist stores to localStorage/sessionStorage or react-native AsyncStorage/file system. The library <a href="https://github.com/acrazing/mobx-sync">mobx-sync</a> is a prefect choice to do this job, which is wrote by myself.</p><p>At first, you can install it by npm or yarn as follow:</p><pre>npm i -S mobx-sync<br># or yarn<br>yarn add mobx-sync</pre><p>And then use it in your web/react-native application to init a autorun to persist store:</p><pre>import { AsyncTrunk } from &#39;mobx-sync/lib/async&#39;</pre><pre>// init your stories<br>const stores = observable({ hello: &#39;world&#39; })</pre><pre>// create a persist trunk<br>const trunk = new AsyncTrunk(stores, { storage: localStorage })</pre><pre>// load stores which is persisted previously<br>trunk.init().then(() =&gt; {<br>  // do any staff after the stores initialized<br>})</pre><p>Store control:</p><ol><li>version control for node/field:</li></ol><p>If you want to ignore the persisted data after update application, for example, the field data structure is changed, you can use @version decorator to change the node or field version. If the persisted data version is different to the current store node version, it will be ignored, and the new initial value will be persisted.</p><pre>import { version } from &#39;mobx-sync/lib/version&#39;</pre><pre>// current version of the node is 1<br>// if the persisted version of the node is not same to it<br>// the persisted store of the node will be ignored<br>@version(1)<br>class Node {<br>  // the version of the field is 2<br>  // the decorator will act on the field<br>  @version(2)<br>  hello = &#39;world&#39;<br>}</pre><p>2. ignore control for field:</p><p>Some times, you may need to omit some fields in your stores when you persist the stores, you can use @ignore decorator to omit it.</p><pre><br>class Node {<br>  // the ignored field will not be persisted<br>  @ignore<br>  ignore = &#39;ignore&#39;<br>}</pre><p>3. type control for field:</p><p>Some times, we not use the pure javascript objects as the store field, for example, mobx.ObservableArray to store array, mobx.ObservableMap to store map data, for those fields, you must init it before call init method to load persisted data:</p><pre>class Node {<br>  array = observable.array&lt;string&gt;()<br>  map = observable.map&lt;string&gt;()<br>}</pre><ul><li>For web application, you may need to use it as synchronous trunk, you can import SyncTrunk from mobx-sync/lib/sync to do it:</li></ul><pre>import { SyncTrunk } from &#39;mobx-sync/lib/sync&#39;</pre><pre>const trunk = new SyncTrunk(stores, { storage: localStorage })<br>trunk.init() // this is synchronous</pre><ul><li>For react-native, you may need to use AsyncStorage to persist data, you just need to change localStorage to AsyncStorage to do it. And more, the AsyncTrunk supports SyncStorage` or AsyncStorage, which are two interface as follow:</li></ul><pre>export interface AsyncStorage {<br>  getItem(key: string): Promise&lt;string | null&gt;;<br>  setItem(key: string, value: string): Promise&lt;void&gt;;<br>  removeItem(key: string): Promise&lt;void&gt;;<br>}</pre><pre>export interface SyncStorage {<br>  getItem(key: string): string | null;<br>  setItem(key: string, value: string): void;<br>  removeItem(key: string): void;<br>}</pre><p>You can get more detailed example at <a href="https://github.com/acrazing/mobx-sync">https://github.com/acrazing/mobx-sync</a>.</p><p>Enjoy your life~</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1dafb8e5f00c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[talib-binding: A synchronous TA-Lib bindings for Node.js]]></title>
            <link>https://medium.com/@joking.young/talib-binding-a-synchronous-ta-lib-bindings-for-node-js-f979713dade2?source=rss-cdcc2f2aa145------2</link>
            <guid isPermaLink="false">https://medium.com/p/f979713dade2</guid>
            <category><![CDATA[fintech]]></category>
            <category><![CDATA[finance]]></category>
            <category><![CDATA[trading]]></category>
            <category><![CDATA[talib]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Junbao Yang]]></dc:creator>
            <pubDate>Sat, 14 Oct 2017 10:34:45 GMT</pubDate>
            <atom:updated>2017-10-14T11:06:15.519Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://ta-lib.org/">TA-Lib</a> is widely used by trading software developers requiring to perform technical analysis of financial market data. Includes 200 indicators such as ADX, MACD, RSI, Stochastic, Bollinger Bands etc…And supports multiple languages just like C/C++, Java, Perl, Python and 100% Managed .NET. But, unfortunately, it does not support Node.js officially.</p><p>There is an unofficial bindings for Node.js, which is called <a href="https://github.com/oransel/node-talib">talib</a>. It could be called as follow:</p><pre>var talib = require(&#39;talib&#39;);</pre><pre>// market data as arrays<br>var marketData = { open: [...], close: [...], high: [...], low: [...], volume: [...] };<br><br>// execute Average Directional Movement Index indicator with time period 9<br>talib.execute({<br>    name: &quot;ADX&quot;,<br>    startIdx: 0,<br>    endIdx: marketData.close.length - 1,<br>    high: marketData.high,<br>    low: marketData.low,<br>    close: marketData.close,<br>    optInTimePeriod: 9<br>}, function (err, result) {<br><br>    console.log(&quot;ADX Function Results:&quot;);<br>    console.log(result);<br><br>});</pre><p>If you use it, you will find it is very hard to use! For example:</p><ul><li>must call API asynchronously, complicates the control-flow.</li><li>use reflect to call API, the parameters are implicit.</li><li>build static shared library before build addon, which dependents on platform, could not install on windows system.</li></ul><p>With so much problem, so I write a new binding for it. You could get it by run:</p><pre>npm install -S talib-binding</pre><pre># OR var yarn</pre><pre>yarn add talib-binding</pre><p>Or view source code at <a href="https://github.com/acrazing/talib-binding-node">https://github.com/acrazing/talib-binding-node</a>.</p><p>It is very simple to use synchronously:</p><pre>import * as talib from &#39;talib-binding&#39;</pre><pre>const sar = talib.SAR(<br>    [2, 3, 4, 5], /* inHigh */<br>    [1, 2, 3, 4], /* inLow */<br>    0.02, /* optAcceleration_Factor, optional */<br>    0.2, /* optAF_Maximum, optional */<br>    0, /* startIdx, optional */<br>    3 /* endIdx, optional */<br>)</pre><pre>console.log(sar)<br>// [ 1, 1.04, 1.1584 ]</pre><p>And, there are more features:</p><ul><li>All the API is synchronous.</li><li>You could input a Record array to replace required parameters, just like inHigh, inLow , and inReal etc.</li><li>All the code is generated by script, build the addon directly, so you could install it on windows system directly.</li><li>The types for TypeScript is generated yet, you could use it in TypeScript project directly.</li></ul><p>Enjoy your life~</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f979713dade2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>