steph

所属分类:编程语言基础
开发工具:JavaScript
文件大小:0KB
下载次数:0
上传日期:2020-08-22 21:49:36
上 传 者sh-1993
说明:  steph编程语言
(The steph programming language)

文件列表:
.eslintrc.json (244, 2020-08-22)
.npmrc (39, 2020-08-22)
.nvmrc (9, 2020-08-22)
.pnp.js (689248, 2020-08-22)
.prettierrc.json (113, 2020-08-22)
.yarn/ (0, 2020-08-22)
.yarn/cache/ (0, 2020-08-22)
.yarn/cache/@babel-code-frame-npm-7.10.4-ab1ee3c93e-05245d3b22.zip (4203, 2020-08-22)
.yarn/cache/@babel-core-npm-7.11.1-0e940c9b00-c6bb33b1f7.zip (59844, 2020-08-22)
.yarn/cache/@babel-generator-npm-7.11.0-e3fecb0d13-aec10e0792.zip (33710, 2020-08-22)
.yarn/cache/@babel-helper-function-name-npm-7.10.4-153d80f559-41ab8f48bb.zip (4109, 2020-08-22)
.yarn/cache/@babel-helper-get-function-arity-npm-7.10.4-29a99c32bb-4f0ddd4340.zip (3022, 2020-08-22)
.yarn/cache/@babel-helper-member-expression-to-functions-npm-7.11.0-4510369a62-745f0697ca.zip (5087, 2020-08-22)
.yarn/cache/@babel-helper-module-imports-npm-7.10.4-f55d85af2c-84d03b58e7.zip (6828, 2020-08-22)
.yarn/cache/@babel-helper-module-transforms-npm-7.11.0-58f745effc-8b74d0a729.zip (11492, 2020-08-22)
.yarn/cache/@babel-helper-optimise-call-expression-npm-7.10.4-135301e242-70dd5a6daf.zip (3191, 2020-08-22)
.yarn/cache/@babel-helper-replace-supers-npm-7.10.4-8bf69fb844-2d7e0627cd.zip (4429, 2020-08-22)
.yarn/cache/@babel-helper-simple-access-npm-7.10.4-0a4bf355e6-a7ce52a229.zip (3568, 2020-08-22)
.yarn/cache/@babel-helper-split-export-declaration-npm-7.11.0-d39c69702f-ddfc44d0cf.zip (3468, 2020-08-22)
.yarn/cache/@babel-helper-validator-identifier-npm-7.10.4-0689d787fa-25098ef842.zip (9184, 2020-08-22)
.yarn/cache/@babel-helpers-npm-7.10.4-5e11989f8d-96859c490a.zip (18243, 2020-08-22)
.yarn/cache/@babel-highlight-npm-7.10.4-c7ff18fbba-c167b938af.zip (3643, 2020-08-22)
.yarn/cache/@babel-parser-npm-7.11.0-8f5cc446ee-c9b8b5fcba.zip (335607, 2020-08-22)
.yarn/cache/@babel-parser-npm-7.11.2-62c898a129-1de8400886.zip (431998, 2020-08-22)
.yarn/cache/@babel-template-npm-7.10.4-521586243b-23a5c4f7ab.zip (10667, 2020-08-22)
.yarn/cache/@babel-traverse-npm-7.11.0-f97e87ce5c-81e4bb3020.zip (49200, 2020-08-22)
.yarn/cache/@babel-types-npm-7.11.0-3a64f51f6c-46e2fcd49d.zip (128362, 2020-08-22)
.yarn/cache/@concordance-react-npm-2.0.0-94535bd4a4-9df1d32f53.zip (8742, 2020-08-22)
.yarn/cache/@nodelib-fs.scandir-npm-2.1.3-92e0b8f0d5-1f100655dd.zip (13086, 2020-08-22)
.yarn/cache/@nodelib-fs.stat-npm-2.0.3-be9eaa5ef7-1bfdb2f419.zip (8680, 2020-08-22)
.yarn/cache/@nodelib-fs.walk-npm-1.2.4-1ae6c97d00-f4bffba16c.zip (15699, 2020-08-22)
.yarn/cache/@sindresorhus-is-npm-0.14.0-9f906ea34b-da26389d6e.zip (12304, 2020-08-22)
.yarn/cache/@szmarczak-http-timer-npm-1.1.2-ea82ca2d55-a46ec85423.zip (3818, 2020-08-22)
.yarn/cache/@types-color-name-npm-1.1.1-00b0925070-8311db94a9.zip (3212, 2020-08-22)
.yarn/cache/@types-glob-npm-7.1.3-44516e2aab-633bf1dda9.zip (3255, 2020-08-22)
.yarn/cache/@types-keyv-npm-3.1.1-779a80f2c7-3aaf557d5b.zip (3221, 2020-08-22)
.yarn/cache/@types-minimatch-npm-3.0.3-c8b0625f84-672ccdac19.zip (3864, 2020-08-22)
.yarn/cache/@types-node-npm-14.0.27-d33df6dc81-54ecf408eb.zip (124082, 2020-08-22)
.yarn/cache/@types-normalize-package-data-npm-2.4.0-ed928aaaa8-6d077e73be.zip (2917, 2020-08-22)
... ...

[![npm version](https://badge.fury.io/js/steph-js.svg)](https://badge.fury.io/js/steph-js) # Steph - Ramda Style JS Do you like Ramda style js? Me too, in fact, I kinda hate js without it. Steph is a (spicy) javascript flavor that enables such a style. If you're wondering why that's useful I recommend reading these articles: - [Why Ramda?](https://fr.umio.us/why-ramda/) - [Thinking in Ramda](https://randycoulman.com/blog/2016/05/24/thinking-in-ramda-getting-started/) ## Ramda as a standard library Ramda is always in scope ```javascript const takeTheGoodOneAndAddFive = pipe(prop('good'), add(5)) console.log(takeTheGoodOneAndAddFive({good: 4})) // => 9 ``` ## Curried by default (Just like Steph) ```javascript const myEquals = (a, b) => a === b const myEquals5 = myEquals(5) console.log(myEquals5(5)) // => true console.log(myEquals5(666)) // => false ``` ## Installation Steph is published to npm. With yarn: ```shell script yarn add steph-js ``` With npm: ```shell script npm install steph-js ``` ## Command line The following command will compile and print the js version of `file-to-compile` ```shell script steph file-to-compile ``` The compiler will add a `require` or `import` for Ramda if you use the `--ramdaImport` or `-ri` flag, it can be set to `node` or to `es6`. For example, you can pipe straight to node like so: ```shell script steph file-to-compile -ri node | node - ``` Specifying `-` as the file will read the source from stdin. For example, the following command will print `6` ```shell script echo "console.log(add(5)(1))" | steph - -ri node | node - ``` ## Implementation steph performs a babel traversal which performs the following transformations: - Wrap function expressions and arrow functions in a call to R.curry - Convert unbound identifiers that exist in Ramda into a `R.` member access This has the following implications: - Functions are curried by default - Ramda acts as a sort of standard library - Most js files that babel can compile are valid Steph. You can use your usual IDE. - JS interop isn't handled (yet?). You can freely call Steph from js and vice-versa, but js functions will not be curried automatically. - Classic-style function declarations are not allowed. Arrow functions are fine (`() => {}`) and so are function expressions `function () {}`. However, this will throw an error at compile time: `function name() {}` ## Setting up a project ### Using the babel plugin First install the dependencies: ```shell script yarn add -D steph-js babel-plugin-steph-js ramda ``` Then add an override to your `.babelrc.json`: ```json5 { "overrides": [ { "test": "**/*.steph.js", "plugins": [ ["babel-plugin-steph-js", { "ramdaImport": "none" // See the command line section for more import options }] ] } ] } ``` ### Using the eslint plugin If you're using eslint then, depending on your configuration, it might complain that the Ramda functions aren't declared. You can use `eslint-plugin-ramda-env` to add them your global scope. Assuming Ramda is already installed, start by installing the plugin: ```shell script yarn add -D eslint-plugin-ramda-env ``` In your `.eslintrc.json` file, add the plugin to the plugins list: ```json {"plugins": ["ramda-env"]} ``` Then use it in the `overrides` section: ```json { "overrides": [ { "files": ["*.steph.js"], "env": { "ramda-env/ramda": true } } ] } ``` This plugin only exports the Ramda environment, if you want actual linting, check out: https://github.com/ramda/eslint-plugin-ramda ## Future steps - Improve cli code, possibly using a library. Add standard cli features. - Add example project that uses steph - Consider adding literals for basic Ramda functions such as `prop`, `path` and `index`. - Think of cool stuff to do with this ## Acknowledgement Thanks a lot to: - [babel](https://babeljs.io/) - Great code, great libs and great error messages! - [Ramda](https://ramdajs.com/) - Thanks for showing me that js can be beautiful! - [@idok](https://github.com/idok) and [@yuvalnissan](https://github.com/yuvalnissan) - They're my bosses at wix.com and they're great! Plus, [wix.com](https://www.wix.com/jobs/home) is a great company to work for, IMO. - This project is developed using, among others: - [node](https://nodejs.org/en/) - [yarn](https://yarnpkg.com/) - [ava](https://github.com/avajs/ava) - [husky](https://github.com/typicode/husky) - [eslint](https://eslint.org/) - [prettier](https://prettier.io/)

近期下载者

相关文件


收藏者