thlorenz/es6ify — dự án mã nguồn mở — đang có 591 sao GitHub. browserify >=v2 transform to compile JavaScript.next (ES6) to JavaScript.current (ES5) on the fly.
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
function that returns a TransformStream when called with a file
Type
function
es6ify::compileFile(file, src) → {string}
Compile function, exposed to be used from other libraries, not needed when using es6ify as a transform.
Parameters:
Name
Type
Description
file
string
name of the file that is being compiled to ES5
src
string
source of the file being compiled to ES5
Source:
index.js
,
lineno 20
Returns:
compiled source
Type
string
es6ify::configure(filePattern) → {function}
Configurable es6ify transform function that allows specifying the filePattern of files to be compiled.
Parameters:
Name
Type
Argument
Description
filePattern
string
<optional>
(default: `/.js$/) pattern of files that will be es6ified
Source:
index.js
,
lineno 112
Returns:
function that returns a TransformStream when called with a file
Type
function
generated with docme
Examples
es6ify.configure(filePattern : Regex)
The default file pattern includes all JavaScript files, but you may override it in order to only transform files coming
from a certain directory, with a specific file name and/or extension, etc.
By configuring the regex to exclude ES5 files, you can optimize the performance of the transform. However transforming
ES5 JavaScript will work since it is a subset of ES6.
browserify({ debug: true })
.add(require('es6ify').runtime)
// compile all .js files except the ones coming from node_modules
.transform(require('es6ify').configure(/^(?!.*node_modules)+.+\.js$/))
.require(require.resolve('./src/main.js'), { entry: true })
.bundle()
.pipe(fs.createWriteStream(bundlePath));
es6ify.traceurOverrides
Some features supported by traceur are still experimental: either nonstandard, proposed but not yet standardized, or
just too slow to use for most code. Therefore Traceur disables them by default. They can be enabled by overriding these
options.
For instance to support the async functions (async/await) feature you'd do the following.
When es6ify is run on a development server to help generate the browserify bundle on the fly, it makes sense to only
recompile ES6 files that changed. Therefore es6ify caches previously compiled files and just pulls them from there if no
changes were made to the file.
Source Maps
es6ify instructs the traceur transpiler to generate source maps. It then inlines all original sources and adds the
resulting source map base64 encoded to the bottom of the transformed content. This allows debugging the original ES6
source when using the debug flag with browserify.
If the debug flag is not set, these source maps will be removed by browserify and thus will not be contained inside
your production bundle.
Supported ES6 features
arrowFunctions
var log = msg => console.log(msg);
full example
classes
class Character {
constructor(x, y, name) {
this.x = x;
this.y = y;
}
attack(character) {
console.log('attacking', character);
}
}
class Monster extends Character {
constructor(x, y, name) {
super(x, y);
this.name = name;
this.health_ = 100;
}
attack(character) {
super.attack(character);
}
get isAlive() { return this.health > 0; }
get health() { return this.health_; }
set health(value) {
if (value < 0) throw new Error('Health must be non-negative.');
this.health_ = value;
}
}
var [a, [b], c, d] = ['hello', [', ', 'junk'], ['world']];
console.log(a + b + c); // hello, world
full example
forOf
for (let element of [1, 2, 3]) {
console.log('element:', element);
}
full example
propertyMethods
var object = {
prop: 42,
// No need for function
method() {
return this.prop;
}
};
propertyNameShorthand
var foo = 'foo';
var bar = 'bar';
var obj = { foo, bar };
templateLiterals
var x = 5, y = 10;
console.log(`${x} + ${y} = ${ x + y}`)
// 5 + 10 = 15
restParameters
function printList(listname, ...items) {
console.log('list %s has the following items', listname);
items.forEach(function (item) { console.log(item); });
};
full example
spread
function add(x, y) {
console.log('%d + %d = %d', x, y, x + y);
}
var numbers = [5, 10]
add(...numbers);
// 5 + 10 = 15
};
full example
generators
// A binary tree class.
function Tree(left, label, right) {
this.left = left;
this.label = label;
this.right = right;
}
// A recursive generator that iterates the Tree labels in-order.
function* inorder(t) {
if (t) {
yield* inorder(t.left);
yield t.label;
yield* inorder(t.right);
}
}
// Make a tree
function make(array) {
// Leaf node:
if (array.length == 1) return new Tree(null, array[0], null);
return new Tree(make(array[0]), array[1], make(array[2]));
}
let tree = make([[['a'], 'b', ['c']], 'd', [['e'], 'f', ['g']]]);
console.log('generating tree labels in order:');
// Iterate over it
for (let node of inorder(tree)) {
console.log(node); // a, b, c, d, ...
}
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/thlorenz/es6ify là nguồn chính thức.
thlorenz/es6ify có bao nhiêu sao?
thlorenz/es6ify có 591 sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/thlorenz/es6ify. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
thlorenz/es6ify có phải mã nguồn mở không?
Có — thlorenz/es6ify phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/thlorenz/es6ify.
thlorenz/es6ify còn đang phát triển không?
Commit gần nhất trên thlorenz/es6ify là 9.4 năm trước (theo timestamp GitHub). Repo có 31 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
thlorenz/es6ify dùng license gì?
thlorenz/es6ify phát hành theo license MIT. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
thlorenz/es6ify là gì?
thlorenz/es6ify (thlorenz/es6ify) là dự án JavaScript trên GitHub. Theo mô tả gốc: browserify >=v2 transform to compile JavaScript.next (ES6) to JavaScript.current (ES5) on the fly.
thlorenz/es6ify viết bằng ngôn ngữ gì?
thlorenz/es6ify chủ yếu viết bằng JavaScript. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Đọc đầy đủ README ở tab phía trên.
es6ify có đáng để bạn bỏ thời gian?
ChatGPT, Claude và Perplexity đều đọc được trang này. Hỏi thử xem họ nghĩ gì về es6ify.