Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

RC3 #212

Merged
merged 4 commits into from

2 participants

@mattpowell
Owner

Includes a couple documentation changes and a bug fix for link.js (an external lib).

For issue #202

@mattpowell mattpowell merged commit 71d980d into v0.4.x

1 check failed

Details default The Travis build is in progress
@mattpowell mattpowell was assigned
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 14, 2012
  1. @Jakobo
Commits on Dec 18, 2012
  1. @Jakobo

    Update README.markdown

    Jakobo authored
Commits on Jan 3, 2013
  1. @Jakobo
Commits on Jan 4, 2013
  1. @Jakobo

    Merge pull request #207 from Jakobo/master

    Jakobo authored
    Link.JS upgrade. Fixes #201
This page is out of date. Refresh to see the latest.
Showing with 41 additions and 47 deletions.
  1. +15 −36 README.markdown
  2. +26 −11 src/lib/link.js
View
51 README.markdown
@@ -1,20 +1,8 @@
-<table>
- <tr>
- <th colspan="2">Healthchecks</th>
- </tr>
- <tr>
- <td>master</td>
- <td><a href="http://travis-ci.org/#!/linkedin/inject/branch_summary"><img src="https://secure.travis-ci.org/linkedin/inject.png?branch=master"/></td>
- </tr>
- <tr>
- <td>v0.4.x</td>
- <td><a href="http://travis-ci.org/#!/linkedin/inject/branch_summary"><img src="https://secure.travis-ci.org/linkedin/inject.png?branch=v0.4.x"/></td>
- </tr>
- <tr>
- <td>v0.3.x</td>
- <td><a href="http://travis-ci.org/#!/linkedin/inject/branch_summary"><img src="https://secure.travis-ci.org/linkedin/inject.png?branch=v0.3.x"/></td>
- </tr>
-</table>
+* InjectJS Mailing List: https://groups.google.com/forum/#!forum/injectjs
+* 0.4.x: [![View Summary](https://secure.travis-ci.org/linkedin/inject.png?branch=v0.4.x)](http://travis-ci.org/#!/linkedin/inject/branch_summary)
+* master: [![View Summary](https://secure.travis-ci.org/linkedin/inject.png?branch=master)](http://travis-ci.org/#!/linkedin/inject/branch_summary)
+
+# Welcome
**Inject** (Apache Software License 2.0) is a revolutionary way to manage your dependencies in a *Library Agnostic* way. Some of its major features include:
@@ -24,16 +12,13 @@
* localStorage (load a module once)
* Frustratingly Simple
-Getting Started With Inject
-===
+# Getting Started With Inject
This page is designed to get you up and running with the latest version of Inject. For greater detail, there is an Advanced Usage section, and a guide to the API.
-Download Inject
-===
-The latest version of inject is always available via the source repository at https://github.com/linkedin/inject/downloads. The most recent version is usually at the top, and inside is the required JS and optional HTML files. Copy them to your own server.
+# Download Inject
+The latest version of inject is always available via the source repository at [http://www.injectjs.com/releases](http://www.injectjs.com/releases). The most recent version is usually at the top, and inside is the required JS and optional HTML files. Copy them to your own server.
-Adding Inject to Your Page
-===
+# Adding Inject to Your Page
This walkthrough is assuming you're using a directory called `js` which contains all of your javascript, possibly even this file. It also assumes inside of the `js` directory is a `modules` directory which will contain all of your modules. Your directory layout might look like the following:
```
@@ -49,8 +34,7 @@ This walkthrough is assuming you're using a directory called `js` which contains
The location of the modules directory does not need to be under the `inject.js` file, but it's common practice to group files of similar types together such as JavaScript.
-Starting Your JavaScript
-===
+# Starting Your JavaScript
To use inject, place the following script tags into the `<head>` of your document
```html
@@ -64,8 +48,7 @@ To use inject, place the following script tags into the `<head>` of your documen
* **Inject.setModuleRoot** is the location of ALL your JS modules. Based on the directory structure above, they are located in the `js/modules` directory.
* **require.run** executes your main entry point, whatever it may be. Given the above directory structure, it will run the `program.js` file in your module root (from require.setModuleRoot). The `.js` is added automatically.
-Some Quick Configs
-===
+# Some Quick Configs
Here's some common configuration options you're going to want for Inject
```js
@@ -86,16 +69,13 @@ Inject.setCrossDomain({
});
```
-Writing Some Modules
-===
+# Writing Some Modules
When you're ready to write your own modules, have a look at the [CommonJS Module Examples](https://github.com/linkedin/inject/wiki/CommonJS-Module-Examples) to get started.
-Building From Source
-===
+# Building From Source
We have a whole section on building from source. [Building From Source](https://github.com/linkedin/inject/wiki/0.4.x-Building-Inject-From-Source) has all the juicy details.
-Next Steps
-===
+# Next Steps
From here, you can...
* learn advanced syntax such as Inject.addRule() for custom module routing
@@ -109,8 +89,7 @@ From here, you can...
* learn how to protect your code from JS minifiers
[Common Minification Problems](https://github.com/linkedin/inject/wiki/Common-Minification-Problems)
-On The Shoulders of Giants
-===
+# On The Shoulders of Giants
Inject couldn't be as great as it is without these other rockstar libraries:
* easyXDM: Cross Domain Communication
View
37 src/lib/link.js
@@ -64,9 +64,14 @@ SOFTWARE.
var LinkJS = {};
+// BEGIN LINKJS LIBRARY
+
+// version: 0.12;
+
(function(){
"use strict";
+// if (typeof exports !== 'undefined') exports.parse = parse;
LinkJS.parse = parse;
var hop = {}.hasOwnProperty;
@@ -185,7 +190,7 @@ function ModuleDefinition(source){
this.tokens = [];
this.lexicalEnvironment = {};
-}
+};
ModuleDefinition.prototype = {
@@ -223,7 +228,7 @@ ModuleDefinition.prototype = {
// Import module
output.push(
- i === 0 ? 'var ' : ', ',
+ i == 0 ? 'var ' : ', ',
name, ' = require("', id, '")'
);
}
@@ -231,7 +236,7 @@ ModuleDefinition.prototype = {
// Redeclare variables at the top
for (var i = 0, l = this.declaredVariables.length; i < l; i++){
- output.push(i === 0 ? 'var ' : ', ');
+ output.push(i == 0 ? 'var ' : ', ');
output.push(this.declaredVariables[i]);
}
if (l) output.push(';', newLine);
@@ -293,7 +298,7 @@ ModuleDefinition.prototype = {
for (var i = 0, l = exports.length; i < l; i++){
var e = exports[i], v = e == 'v' ? 'b' : 'v';
output.push(
- i === 0 ? '({}.constructor.defineProperties(this, {' : ',',
+ i == 0 ? '({}.constructor.defineProperties(this, {' : ',',
e, ':{get:function(){return ', e, '},set:function(', v, '){', e, '=', v,'},enumerable:true}'
);
}
@@ -396,16 +401,16 @@ var errorMessages = {
function formatMessage(args){
return errorMessages[args[0]]
- .replace(/\$(\d)/g, function(s, i){ return args[i]; });
+ .replace(/\$(\d)/g, function(s, i){ return args[i]; })
}
function warn(){
console.warn(formatMessage(arguments));
-}
+};
function error(){
throw new Error(formatMessage(arguments));
-}
+};
// Tokenizer
@@ -445,7 +450,7 @@ function couldBeRegExp(){
// TODO: Proper regexp handling, when I find a case for it
var token = previousToken;
return typeof token === 'undefined' ||
- (token.type === Punctuator && '!(=:,[{++--;'.indexOf(token.value) >= 0) ||
+ (token.type === Punctuator && '!(=:,[{++--;&&||^'.indexOf(token.value) >= 0) ||
(token.type === Keyword && isKeyword(token.value));
}
@@ -742,7 +747,7 @@ function lookahead(){
function expect(value){
var token = lex();
if (token.type !== Punctuator || token.value !== value) {
- throw new Error('Unexpected token: ' + token.value);
+ throw new Error('Unexpected token: ' + token.value + ' at line ' + lineNumber);
}
}
@@ -765,9 +770,19 @@ function matchKeyword(keyword){
function matchBlockStart(){
var token = lookahead();
- if (token.type == Keyword)
+ if (token.type == Keyword){
+ if (token.value == 'case'){
+ lex();
+ lex();
+ return true;
+ }
+ if (token.value == 'default'){
+ lex();
+ return true;
+ }
return token.value == 'do' || token.value == 'else' ||
token.value == 'finally' || token.value == 'try';
+ }
return false;
}
@@ -820,7 +835,7 @@ function scanParenthesis(){
while(match(',') || match(';')){
lex();
scanExpression();
- }
+ };
expect(')');
}
Something went wrong with that request. Please try again.