付智勇

no message

正在显示 57 个修改的文件 包含 4288 行增加1 行删除

要显示太多修改。

为保证性能只显示 57 of 57+ 个文件。

1 module.exports = { 1 module.exports = {
2 - uploade:'/Users/fzy/project/koa2_Sequelize_project/uploads/' 2 + uploade:'/Users/fzy/project/koa2_Sequelize_project/uploads/' ///Users/fzy/project/koa2_Sequelize_project/uploads/
3 } 3 }
  1 +var Sequelize = require('sequelize');
  2 +//数据配置
  3 +var sequelize = new Sequelize('saas_3m', 'test_read', "test_read7", {
  4 + // var sequelize = new Sequelize('xuedianyun', 'root', "", {
  5 + //host:'localhost',
  6 + host:'rds9vo3ja79e62m0433jo.mysql.rds.aliyuncs.com',
  7 + dialect: 'mysql',
  8 + pool: {
  9 + max: 10,
  10 + min: 0,
  11 + idle: 1000
  12 + }
  13 +})
  14 +
  15 +module.exports = sequelize
  1 +var sequelize = require('../config');
  2 +var Sequelize = require('sequelize');
  3 +var uuid = require('../util/UuidUtil')
  4 +
  5 +
  6 +var recordInfo = sequelize.define('3m_record_info', {
  7 + id: {
  8 + type: Sequelize.STRING(32),
  9 + defaultValue:uuid.db32(),
  10 + allowNull: false,
  11 + unique: true,
  12 + primaryKey: true,
  13 + field: "id"
  14 + },
  15 + appId: {
  16 + allowNull: false,
  17 + type:Sequelize.STRING(50),
  18 + field: "app_id"
  19 + },
  20 + channel: {
  21 + allowNull: false,
  22 + type:Sequelize.STRING(50),
  23 + field: "channel"
  24 + },
  25 + channelKey:{
  26 + type:Sequelize.STRING(50),
  27 + field: "channel_key"
  28 + },
  29 + uid:{
  30 + type:Sequelize.STRING(50),
  31 + field: "uid"
  32 + },
  33 + userId:{
  34 + type:Sequelize.STRING(50),
  35 + field: "user_id"
  36 + },
  37 + userRole:{
  38 + type:Sequelize.STRING(50),
  39 + field: "user_role"
  40 + },
  41 + userName:{
  42 + type:Sequelize.STRING(50),
  43 + field: "user_name"
  44 + },
  45 + timestamp:{
  46 + type:Sequelize.STRING(50),
  47 + field: "timestamp"
  48 + },
  49 + recordTimestamp:{
  50 + type:Sequelize.STRING(50),
  51 + field: "recordTimestamp"
  52 + },
  53 + createTime:{
  54 + type:Sequelize.STRING(50),
  55 + field: "create_time"
  56 + },
  57 + status:{
  58 + type:Sequelize.INTEGER(1),
  59 + field:'status',
  60 + },
  61 + type:{
  62 + type:Sequelize.INTEGER(1),
  63 + field:'type',
  64 + }
  65 +
  66 +
  67 +}, {
  68 + timestamps: false,
  69 + freezeTableName: true
  70 + });
  71 +
  72 +module.exports = recordInfo;
  1 +var sequelize = require('../config');
  2 +var Sequelize = require('sequelize');
  3 +var uuid = require('../util/UuidUtil')
  4 +
  5 +
  6 +var recordStatus = sequelize.define('3m_record_status', {
  7 + id: {
  8 + type: Sequelize.STRING(32),
  9 + defaultValue:uuid.db32(),
  10 + allowNull: false,
  11 + unique: true,
  12 + primaryKey: true,
  13 + field: "id"
  14 + },
  15 + channel:{
  16 + type:Sequelize.STRING(50),
  17 + field: "channel"
  18 + },
  19 + status:{
  20 + type:Sequelize.INTEGER(1),
  21 + field:'status',
  22 + },
  23 +}, {
  24 + timestamps: false,
  25 + freezeTableName: true
  26 +});
  27 +
  28 +module.exports = recordStatus;
  1 +var sequelize = require('../config');
  2 +var Sequelize = require('sequelize');
  3 +const uuid = require('../util/UuidUtil')
  4 +
  5 +
  6 +var site = sequelize.define('3m_site', {
  7 + id: {
  8 + type: Sequelize.STRING(32),
  9 + defaultValue:uuid.db32(),
  10 + allowNull: false,
  11 + unique: true,
  12 + primaryKey: true,
  13 + field: "id"
  14 + },
  15 + siteId: {
  16 + type:Sequelize.STRING(32),
  17 + field: "siteid"
  18 + },
  19 + siteKey: {
  20 + type:Sequelize.STRING(128),
  21 + field: "site_key"
  22 + },
  23 + startDate:{
  24 + type:Sequelize.TEXT(0),
  25 + field: "startdate"
  26 + },
  27 + endDate:{
  28 + type:Sequelize.STRING(1024),
  29 + field: "enddate"
  30 + },
  31 + aseKey:{
  32 + type:Sequelize.STRING(128),
  33 + field: "ase_key"
  34 + },
  35 + mcuList:{
  36 + type:Sequelize.INTEGER(1),
  37 + field: "mcu_list"
  38 + },
  39 + msList:{
  40 + type:Sequelize.INTEGER(1),
  41 + field: "ms_list"
  42 + },
  43 + rsList:{
  44 + type:Sequelize.INTEGER(1),
  45 + field: "rs_list"
  46 + },
  47 + docList:{
  48 + type:Sequelize.STRING(32),
  49 + field: "doc_list"
  50 + }
  51 +}, {
  52 + timestamps: false,
  53 + freezeTableName: true
  54 + });
  55 +
  56 +module.exports = site;
  1 +var sequelize = require('../config');
  2 +var Sequelize = require('sequelize');
  3 +const uuid = require('../util/UuidUtil')
  4 +
  5 +var studentMeeting = sequelize.define('3m_student_meeting', {
  6 + id: {
  7 + type: Sequelize.STRING(32),
  8 + defaultValue:uuid.db32(),
  9 + allowNull: false,
  10 + unique: true,
  11 + primaryKey: true,
  12 + field: "id"
  13 + },
  14 + studentId: {
  15 + allowNull: false,
  16 + type:Sequelize.STRING(32),
  17 + field: "student_id"
  18 + },
  19 + meetingId: {
  20 + allowNull: false,
  21 + type:Sequelize.STRING(32),
  22 + field: "meeting_id"
  23 + },
  24 + siteId: {
  25 + allowNull: false,
  26 + type:Sequelize.STRING(32),
  27 + field: "site_id"
  28 + },
  29 + status: {
  30 + allowNull: false,
  31 + type:Sequelize.STRING(32),
  32 + field: "status"
  33 + },
  34 + createTime: {
  35 + allowNull: false,
  36 + type:Sequelize.STRING(32),
  37 + field: "create_time"
  38 + }
  39 +},{
  40 + timestamps: false,
  41 + freezeTableName: true
  42 +});
  43 +module.exports = studentMeeting;
  1 +var sequelize = require('../config');
  2 +var Sequelize = require('sequelize');
  3 +var uuid = require('../util/UuidUtil')
  4 +
  5 +
  6 +var user = sequelize.define('3m_user', {
  7 + id: {
  8 + type: Sequelize.STRING(32),
  9 + defaultValue:uuid.db32(),
  10 + allowNull: false,
  11 + unique: true,
  12 + primaryKey: true,
  13 + field: "id"
  14 + },
  15 + loginName: {
  16 + allowNull: false,
  17 + type:Sequelize.STRING(100),
  18 + field: "login_name"
  19 + },
  20 + // IDcard: {
  21 + // allowNull: false,
  22 + // type:Sequelize.STRING(50),
  23 + // field: "IDcard"
  24 + // },
  25 + password: {
  26 + allowNull: false,
  27 + type:Sequelize.STRING(100),
  28 + field: "password"
  29 + },
  30 + // salt:{
  31 + // type:Sequelize.INTEGER(2),
  32 + // field: "salt"
  33 + // },
  34 + companyName:{
  35 + type:Sequelize.STRING(1024),
  36 + field: "company_name"
  37 + },
  38 + userName:{
  39 + type:Sequelize.STRING(64),
  40 + field: "user_name"
  41 + },
  42 + userType:{
  43 + type:Sequelize.INTEGER(1),
  44 + field: "user_type"
  45 + },
  46 + userRole:{
  47 + type:Sequelize.INTEGER(1),
  48 + field: "user_role"
  49 + },
  50 + userEmail:{
  51 + type:Sequelize.INTEGER(1),
  52 + field: "user_email"
  53 + },
  54 + userMobile:{
  55 + type:Sequelize.STRING(32),
  56 + field: "user_mobile"
  57 + },
  58 + createTime:{
  59 + type:Sequelize.DATE,
  60 + defaultValue:Sequelize.NOW,
  61 + field: "create_time"
  62 + },
  63 + endTime:{
  64 + type:Sequelize.DATE,
  65 + field: "end_time"
  66 + },
  67 + content:{
  68 + type:Sequelize.TEXT(1024),
  69 + field: "content"
  70 + },
  71 + serialNo:{
  72 + type:Sequelize.INTEGER(11),
  73 + field: "serial_no"
  74 + },
  75 + siteId:{
  76 + type:Sequelize.STRING(32),
  77 + field: "site_id"
  78 + },
  79 + userStatus:{
  80 + type:Sequelize.INTEGER(11),
  81 + field: "user_status"
  82 + },
  83 + groupId:{
  84 + type:Sequelize.STRING(128),
  85 + field: "group_id"
  86 + },
  87 +}, {
  88 + timestamps: false,
  89 + freezeTableName: true
  90 + });
  91 +
  92 +module.exports = user;
  1 +var sequelize = require('../db2.config');
  2 +var Sequelize = require('sequelize');
  3 +const uuid = require('../util/UuidUtil')
  4 +
  5 +
  6 +var user = sequelize.define('3m_meeting', {
  7 + id: {
  8 + type: Sequelize.STRING(32),
  9 + defaultValue:uuid.db32(),
  10 + allowNull: false,
  11 + unique: true,
  12 + primaryKey: true,
  13 + field: "id"
  14 + },
  15 + meetingNumber: {
  16 + type:Sequelize.STRING(32),
  17 + field: "meeting_number"
  18 + },
  19 + meetingName: {
  20 + type:Sequelize.STRING(128),
  21 + field: "meeting_name"
  22 + },
  23 + meetingContent:{
  24 + type:Sequelize.TEXT(0),
  25 + field: "meeting_content"
  26 + },
  27 + create_user:{
  28 + type:Sequelize.STRING(128),
  29 + field: "create_user"
  30 + },
  31 + createTime:{
  32 + type:Sequelize.DATE,
  33 + defaultValue:Sequelize.NOW,
  34 + field: "create_time"
  35 + },
  36 + beginTime:{
  37 + type:Sequelize.DATE,
  38 + field: "begin_time"
  39 + },
  40 + endTime:{
  41 + type:Sequelize.DATE,
  42 + field: "end_time"
  43 + },
  44 + inviteUser:{
  45 + type:Sequelize.STRING(1024),
  46 + field: "invite_user"
  47 + },
  48 + meetingType:{
  49 + type:Sequelize.INTEGER(4),
  50 + field: "meeting_type"
  51 + },
  52 + meetingStatus:{
  53 + type:Sequelize.STRING(32),
  54 + field: "meeting_status"
  55 + },
  56 + userIp:{
  57 + type:Sequelize.INTEGER(11),
  58 + field: "user_ip"
  59 + },
  60 + meetingKey:{
  61 + type:Sequelize.STRING(128),
  62 + field: "meeting_key"
  63 + },
  64 + hostPassword:{
  65 + type:Sequelize.STRING(12),
  66 + field: "host_password"
  67 + },
  68 + presenterPassword:{
  69 + type:Sequelize.STRING(12),
  70 + field: "presenter_password"
  71 + },
  72 + assistantPassword:{
  73 + type:Sequelize.STRING(12),
  74 + field: "assistant_password"
  75 + },
  76 + attendeePassword:{
  77 + type:Sequelize.STRING(12),
  78 + field: "attendee_password"
  79 + },
  80 + capacity:{
  81 + type:Sequelize.INTEGER(11),
  82 + field: "capacity"
  83 + },
  84 + topNodeId:{
  85 + type:Sequelize.STRING(32),
  86 + field: "top_node_id"
  87 + },
  88 + topNodeAddr:{
  89 + type:Sequelize.STRING(128),
  90 + field: "top_node_addr"
  91 + },
  92 + userData:{
  93 + type:Sequelize.STRING(128),
  94 + field: "user_data"
  95 + },
  96 + siteId:{
  97 + type:Sequelize.STRING(32),
  98 + field: "site_id"
  99 + },
  100 + classroomNumber:{
  101 + type:Sequelize.STRING(128),
  102 + field: "classroom_number"
  103 + },
  104 + uiLanguage:{
  105 + type:Sequelize.INTEGER(11),
  106 + field: "ui_language"
  107 + },
  108 + isPublic:{
  109 + type:Sequelize.INTEGER(11),
  110 + field: "is_public"
  111 + },
  112 + controlMode:{
  113 + type:Sequelize.INTEGER(11),
  114 + field: "control_mode"
  115 + },
  116 + micAuto:{
  117 + type:Sequelize.INTEGER(11),
  118 + field: "mic_auto"
  119 + },
  120 + hasInteraction:{
  121 + type:Sequelize.INTEGER(11),
  122 + field: "has_interaction"
  123 + },
  124 + autoRecord:{
  125 + type:Sequelize.INTEGER(11),
  126 + field: "auto_record"
  127 + },
  128 + maxVideoChannels:{
  129 + type:Sequelize.INTEGER(11),
  130 + field: "max_videoChannels"
  131 + },
  132 + maxAudioChannels:{
  133 + type:Sequelize.INTEGER(11),
  134 + field: "max_audioChannels"
  135 + },
  136 + videoQuality:{
  137 + type:Sequelize.INTEGER(11),
  138 + field: "video_quality"
  139 + },
  140 + pagenaviUserprivilege:{
  141 + type:Sequelize.INTEGER(11),
  142 + field: "pagenavi_Userprivilege"
  143 + },
  144 + markerUserprivilege:{
  145 + type:Sequelize.INTEGER(11),
  146 + field: "marker_Userprivilege"
  147 + },
  148 + chatToNormalUserprivilege:{
  149 + type:Sequelize.INTEGER(11),
  150 + field: "chatToNormal_Userprivilege"
  151 + },
  152 + chatToHostUserprivilege:{
  153 + type:Sequelize.INTEGER(11),
  154 + field: "chatToHost_Userprivilege"
  155 + },
  156 + docModule:{
  157 + type:Sequelize.INTEGER(11),
  158 + field: "doc_module"
  159 + },
  160 + screenModule:{
  161 + type:Sequelize.INTEGER(11),
  162 + field: "screen_module"
  163 + },
  164 + mediaModule:{
  165 + type:Sequelize.INTEGER(11),
  166 + field: "media_module"
  167 + },
  168 + whiteboardModule:{
  169 + type:Sequelize.INTEGER(11),
  170 + field: "whiteboard_module"
  171 + },
  172 + recordModule:{
  173 + type:Sequelize.INTEGER(11),
  174 + field: "record_module"
  175 + },
  176 + videoModule:{
  177 + type:Sequelize.INTEGER(11),
  178 + field: "video_module"
  179 + },
  180 + userListModule:{
  181 + type:Sequelize.INTEGER(11),
  182 + field: "userList_module"
  183 + },
  184 + chatModule:{
  185 + type:Sequelize.INTEGER(11),
  186 + field: "chat_module"
  187 + },
  188 + cycle:{
  189 + type:Sequelize.INTEGER(11),
  190 + field: "cycle"
  191 + },
  192 + repeatmode:{
  193 + type:Sequelize.INTEGER(11),
  194 + field: "repeatmode"
  195 + },
  196 + endmode:{
  197 + type:Sequelize.INTEGER(11),
  198 + field: "endmode"
  199 + },
  200 + finalenddate:{
  201 + type:Sequelize.INTEGER(11),
  202 + field: "finalenddate"
  203 + },
  204 + endcount:{
  205 + type:Sequelize.INTEGER(11),
  206 + field: "endcount"
  207 + },
  208 + repeatday:{
  209 + type:Sequelize.INTEGER(11),
  210 + field: "repeatday"
  211 + },
  212 + repeatweek:{
  213 + type:Sequelize.INTEGER(11),
  214 + field: "repeatweek"
  215 + },
  216 + repeatmonthday:{
  217 + type:Sequelize.INTEGER(11),
  218 + field: "repeatmonthday"
  219 + },
  220 + repeatmonthweekweek:{
  221 + type:Sequelize.INTEGER(11),
  222 + field: "repeatmonthweekweek"
  223 + },
  224 + repeatmonthweekday:{
  225 + type:Sequelize.INTEGER(11),
  226 + field: "repeatmonthweekday"
  227 + },
  228 + frequency:{
  229 + type:Sequelize.INTEGER(11),
  230 + field: "frequency"
  231 + },
  232 + monthType:{
  233 + type:Sequelize.INTEGER(11),
  234 + field: "month_type"
  235 + },
  236 + inviterRadio:{
  237 + type:Sequelize.INTEGER(11),
  238 + field: "inviter_radio"
  239 + },
  240 + aheadTime:{
  241 + type:Sequelize.INTEGER(11),
  242 + field: "ahead_time"
  243 + },
  244 + chatInterval:{
  245 + type:Sequelize.INTEGER(11),
  246 + field: "chat_interval"
  247 + },
  248 + h5Module:{
  249 + type:Sequelize.INTEGER(11),
  250 + field: "h5_Module"
  251 + },
  252 + // reservationNumber:{
  253 + // type:Sequelize.INTEGER(11),
  254 + // field: "reservation_number"
  255 + // },
  256 +}, {
  257 + timestamps: false,
  258 + freezeTableName: true
  259 + });
  260 +
  261 +module.exports = user;
  1 +../node-gyp/bin/node-gyp.js
  1 +../rimraf/bin.js
  1 +Copyright (c) 2015, Rebecca Turner <me@re-becca.org>
  2 +
  3 +Permission to use, copy, modify, and/or distribute this software for any
  4 +purpose with or without fee is hereby granted, provided that the above
  5 +copyright notice and this permission notice appear in all copies.
  6 +
  7 +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  8 +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  9 +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  10 +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  11 +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  12 +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  13 +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  14 +
  1 +aproba
  2 +======
  3 +
  4 +A ridiculously light-weight function argument validator
  5 +
  6 +```
  7 +var validate = require("aproba")
  8 +
  9 +function myfunc(a, b, c) {
  10 + // `a` must be a string, `b` a number, `c` a function
  11 + validate('SNF', arguments) // [a,b,c] is also valid
  12 +}
  13 +
  14 +myfunc('test', 23, function () {}) // ok
  15 +myfunc(123, 23, function () {}) // type error
  16 +myfunc('test', 23) // missing arg error
  17 +myfunc('test', 23, function () {}, true) // too many args error
  18 +
  19 +```
  20 +
  21 +Valid types are:
  22 +
  23 +| type | description
  24 +| :--: | :----------
  25 +| * | matches any type
  26 +| A | `Array.isArray` OR an `arguments` object
  27 +| S | typeof == string
  28 +| N | typeof == number
  29 +| F | typeof == function
  30 +| O | typeof == object and not type A and not type E
  31 +| B | typeof == boolean
  32 +| E | `instanceof Error` OR `null` **(special: see below)**
  33 +| Z | == `null`
  34 +
  35 +Validation failures throw one of three exception types, distinguished by a
  36 +`code` property of `EMISSINGARG`, `EINVALIDTYPE` or `ETOOMANYARGS`.
  37 +
  38 +If you pass in an invalid type then it will throw with a code of
  39 +`EUNKNOWNTYPE`.
  40 +
  41 +If an **error** argument is found and is not null then the remaining
  42 +arguments are optional. That is, if you say `ESO` then that's like using a
  43 +non-magical `E` in: `E|ESO|ZSO`.
  44 +
  45 +### But I have optional arguments?!
  46 +
  47 +You can provide more than one signature by separating them with pipes `|`.
  48 +If any signature matches the arguments then they'll be considered valid.
  49 +
  50 +So for example, say you wanted to write a signature for
  51 +`fs.createWriteStream`. The docs for it describe it thusly:
  52 +
  53 +```
  54 +fs.createWriteStream(path[, options])
  55 +```
  56 +
  57 +This would be a signature of `SO|S`. That is, a string and and object, or
  58 +just a string.
  59 +
  60 +Now, if you read the full `fs` docs, you'll see that actually path can ALSO
  61 +be a buffer. And options can be a string, that is:
  62 +```
  63 +path <String> | <Buffer>
  64 +options <String> | <Object>
  65 +```
  66 +
  67 +To reproduce this you have to fully enumerate all of the possible
  68 +combinations and that implies a signature of `SO|SS|OO|OS|S|O`. The
  69 +awkwardness is a feature: It reminds you of the complexity you're adding to
  70 +your API when you do this sort of thing.
  71 +
  72 +
  73 +### Browser support
  74 +
  75 +This has no dependencies and should work in browsers, though you'll have
  76 +noisier stack traces.
  77 +
  78 +### Why this exists
  79 +
  80 +I wanted a very simple argument validator. It needed to do two things:
  81 +
  82 +1. Be more concise and easier to use than assertions
  83 +
  84 +2. Not encourage an infinite bikeshed of DSLs
  85 +
  86 +This is why types are specified by a single character and there's no such
  87 +thing as an optional argument.
  88 +
  89 +This is not intended to validate user data. This is specifically about
  90 +asserting the interface of your functions.
  91 +
  92 +If you need greater validation, I encourage you to write them by hand or
  93 +look elsewhere.
  94 +
  1 +'use strict'
  2 +
  3 +function isArguments (thingy) {
  4 + return thingy != null && typeof thingy === 'object' && thingy.hasOwnProperty('callee')
  5 +}
  6 +
  7 +var types = {
  8 + '*': {label: 'any', check: function () { return true }},
  9 + A: {label: 'array', check: function (thingy) { return Array.isArray(thingy) || isArguments(thingy) }},
  10 + S: {label: 'string', check: function (thingy) { return typeof thingy === 'string' }},
  11 + N: {label: 'number', check: function (thingy) { return typeof thingy === 'number' }},
  12 + F: {label: 'function', check: function (thingy) { return typeof thingy === 'function' }},
  13 + O: {label: 'object', check: function (thingy) { return typeof thingy === 'object' && thingy != null && !types.A.check(thingy) && !types.E.check(thingy) }},
  14 + B: {label: 'boolean', check: function (thingy) { return typeof thingy === 'boolean' }},
  15 + E: {label: 'error', check: function (thingy) { return thingy instanceof Error }},
  16 + Z: {label: 'null', check: function (thingy) { return thingy == null }}
  17 +}
  18 +
  19 +function addSchema (schema, arity) {
  20 + var group = arity[schema.length] = arity[schema.length] || []
  21 + if (group.indexOf(schema) === -1) group.push(schema)
  22 +}
  23 +
  24 +var validate = module.exports = function (rawSchemas, args) {
  25 + if (arguments.length !== 2) throw wrongNumberOfArgs(['SA'], arguments.length)
  26 + if (!rawSchemas) throw missingRequiredArg(0, 'rawSchemas')
  27 + if (!args) throw missingRequiredArg(1, 'args')
  28 + if (!types.S.check(rawSchemas)) throw invalidType(0, ['string'], rawSchemas)
  29 + if (!types.A.check(args)) throw invalidType(1, ['array'], args)
  30 + var schemas = rawSchemas.split('|')
  31 + var arity = {}
  32 +
  33 + schemas.forEach(function (schema) {
  34 + for (var ii = 0; ii < schema.length; ++ii) {
  35 + var type = schema[ii]
  36 + if (!types[type]) throw unknownType(ii, type)
  37 + }
  38 + if (/E.*E/.test(schema)) throw moreThanOneError(schema)
  39 + addSchema(schema, arity)
  40 + if (/E/.test(schema)) {
  41 + addSchema(schema.replace(/E.*$/, 'E'), arity)
  42 + addSchema(schema.replace(/E/, 'Z'), arity)
  43 + if (schema.length === 1) addSchema('', arity)
  44 + }
  45 + })
  46 + var matching = arity[args.length]
  47 + if (!matching) {
  48 + throw wrongNumberOfArgs(Object.keys(arity), args.length)
  49 + }
  50 + for (var ii = 0; ii < args.length; ++ii) {
  51 + var newMatching = matching.filter(function (schema) {
  52 + var type = schema[ii]
  53 + var typeCheck = types[type].check
  54 + return typeCheck(args[ii])
  55 + })
  56 + if (!newMatching.length) {
  57 + var labels = matching.map(function (schema) {
  58 + return types[schema[ii]].label
  59 + }).filter(function (schema) { return schema != null })
  60 + throw invalidType(ii, labels, args[ii])
  61 + }
  62 + matching = newMatching
  63 + }
  64 +}
  65 +
  66 +function missingRequiredArg (num) {
  67 + return newException('EMISSINGARG', 'Missing required argument #' + (num + 1))
  68 +}
  69 +
  70 +function unknownType (num, type) {
  71 + return newException('EUNKNOWNTYPE', 'Unknown type ' + type + ' in argument #' + (num + 1))
  72 +}
  73 +
  74 +function invalidType (num, expectedTypes, value) {
  75 + var valueType
  76 + Object.keys(types).forEach(function (typeCode) {
  77 + if (types[typeCode].check(value)) valueType = types[typeCode].label
  78 + })
  79 + return newException('EINVALIDTYPE', 'Argument #' + (num + 1) + ': Expected ' +
  80 + englishList(expectedTypes) + ' but got ' + valueType)
  81 +}
  82 +
  83 +function englishList (list) {
  84 + return list.join(', ').replace(/, ([^,]+)$/, ' or $1')
  85 +}
  86 +
  87 +function wrongNumberOfArgs (expected, got) {
  88 + var english = englishList(expected)
  89 + var args = expected.every(function (ex) { return ex.length === 1 })
  90 + ? 'argument'
  91 + : 'arguments'
  92 + return newException('EWRONGARGCOUNT', 'Expected ' + english + ' ' + args + ' but got ' + got)
  93 +}
  94 +
  95 +function moreThanOneError (schema) {
  96 + return newException('ETOOMANYERRORTYPES',
  97 + 'Only one error type per argument signature is allowed, more than one found in "' + schema + '"')
  98 +}
  99 +
  100 +function newException (code, msg) {
  101 + var e = new Error(msg)
  102 + e.code = code
  103 + if (Error.captureStackTrace) Error.captureStackTrace(e, validate)
  104 + return e
  105 +}
  1 +{
  2 + "_args": [
  3 + [
  4 + {
  5 + "raw": "aproba@^1.0.3",
  6 + "scope": null,
  7 + "escapedName": "aproba",
  8 + "name": "aproba",
  9 + "rawSpec": "^1.0.3",
  10 + "spec": ">=1.0.3 <2.0.0",
  11 + "type": "range"
  12 + },
  13 + "/Users/fzy/project/koa2_Sequelize_project/node_modules/gauge"
  14 + ]
  15 + ],
  16 + "_from": "aproba@>=1.0.3 <2.0.0",
  17 + "_id": "aproba@1.2.0",
  18 + "_inCache": true,
  19 + "_location": "/aproba",
  20 + "_nodeVersion": "8.5.0",
  21 + "_npmOperationalInternal": {
  22 + "host": "s3://npm-registry-packages",
  23 + "tmp": "tmp/aproba-1.2.0.tgz_1505861292502_0.3447994305752218"
  24 + },
  25 + "_npmUser": {
  26 + "name": "iarna",
  27 + "email": "me@re-becca.org"
  28 + },
  29 + "_npmVersion": "5.4.2",
  30 + "_phantomChildren": {},
  31 + "_requested": {
  32 + "raw": "aproba@^1.0.3",
  33 + "scope": null,
  34 + "escapedName": "aproba",
  35 + "name": "aproba",
  36 + "rawSpec": "^1.0.3",
  37 + "spec": ">=1.0.3 <2.0.0",
  38 + "type": "range"
  39 + },
  40 + "_requiredBy": [
  41 + "/gauge"
  42 + ],
  43 + "_resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz",
  44 + "_shasum": "6802e6264efd18c790a1b0d517f0f2627bf2c94a",
  45 + "_shrinkwrap": null,
  46 + "_spec": "aproba@^1.0.3",
  47 + "_where": "/Users/fzy/project/koa2_Sequelize_project/node_modules/gauge",
  48 + "author": {
  49 + "name": "Rebecca Turner",
  50 + "email": "me@re-becca.org"
  51 + },
  52 + "bugs": {
  53 + "url": "https://github.com/iarna/aproba/issues"
  54 + },
  55 + "dependencies": {},
  56 + "description": "A ridiculously light-weight argument validator (now browser friendly)",
  57 + "devDependencies": {
  58 + "standard": "^10.0.3",
  59 + "tap": "^10.0.2"
  60 + },
  61 + "directories": {
  62 + "test": "test"
  63 + },
  64 + "dist": {
  65 + "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==",
  66 + "shasum": "6802e6264efd18c790a1b0d517f0f2627bf2c94a",
  67 + "tarball": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz"
  68 + },
  69 + "files": [
  70 + "index.js"
  71 + ],
  72 + "gitHead": "ee43ce68c9992e8f9d0d925dc2b1f2e1e5c976de",
  73 + "homepage": "https://github.com/iarna/aproba",
  74 + "keywords": [
  75 + "argument",
  76 + "validate"
  77 + ],
  78 + "license": "ISC",
  79 + "main": "index.js",
  80 + "maintainers": [
  81 + {
  82 + "name": "iarna",
  83 + "email": "me@re-becca.org"
  84 + }
  85 + ],
  86 + "name": "aproba",
  87 + "optionalDependencies": {},
  88 + "readme": "aproba\n======\n\nA ridiculously light-weight function argument validator\n\n```\nvar validate = require(\"aproba\")\n\nfunction myfunc(a, b, c) {\n // `a` must be a string, `b` a number, `c` a function\n validate('SNF', arguments) // [a,b,c] is also valid\n}\n\nmyfunc('test', 23, function () {}) // ok\nmyfunc(123, 23, function () {}) // type error\nmyfunc('test', 23) // missing arg error\nmyfunc('test', 23, function () {}, true) // too many args error\n\n```\n\nValid types are:\n\n| type | description\n| :--: | :----------\n| * | matches any type\n| A | `Array.isArray` OR an `arguments` object\n| S | typeof == string\n| N | typeof == number\n| F | typeof == function\n| O | typeof == object and not type A and not type E\n| B | typeof == boolean\n| E | `instanceof Error` OR `null` **(special: see below)**\n| Z | == `null`\n\nValidation failures throw one of three exception types, distinguished by a\n`code` property of `EMISSINGARG`, `EINVALIDTYPE` or `ETOOMANYARGS`.\n\nIf you pass in an invalid type then it will throw with a code of\n`EUNKNOWNTYPE`.\n\nIf an **error** argument is found and is not null then the remaining\narguments are optional. That is, if you say `ESO` then that's like using a\nnon-magical `E` in: `E|ESO|ZSO`.\n\n### But I have optional arguments?!\n\nYou can provide more than one signature by separating them with pipes `|`.\nIf any signature matches the arguments then they'll be considered valid.\n\nSo for example, say you wanted to write a signature for\n`fs.createWriteStream`. The docs for it describe it thusly:\n\n```\nfs.createWriteStream(path[, options])\n```\n\nThis would be a signature of `SO|S`. That is, a string and and object, or\njust a string.\n\nNow, if you read the full `fs` docs, you'll see that actually path can ALSO\nbe a buffer. And options can be a string, that is:\n```\npath <String> | <Buffer>\noptions <String> | <Object>\n```\n\nTo reproduce this you have to fully enumerate all of the possible\ncombinations and that implies a signature of `SO|SS|OO|OS|S|O`. The\nawkwardness is a feature: It reminds you of the complexity you're adding to\nyour API when you do this sort of thing.\n\n\n### Browser support\n\nThis has no dependencies and should work in browsers, though you'll have\nnoisier stack traces.\n\n### Why this exists\n\nI wanted a very simple argument validator. It needed to do two things:\n\n1. Be more concise and easier to use than assertions\n\n2. Not encourage an infinite bikeshed of DSLs\n\nThis is why types are specified by a single character and there's no such\nthing as an optional argument. \n\nThis is not intended to validate user data. This is specifically about\nasserting the interface of your functions.\n\nIf you need greater validation, I encourage you to write them by hand or\nlook elsewhere.\n\n",
  89 + "readmeFilename": "README.md",
  90 + "repository": {
  91 + "type": "git",
  92 + "url": "git+https://github.com/iarna/aproba.git"
  93 + },
  94 + "scripts": {
  95 + "test": "standard && tap -j3 test/*.js"
  96 + },
  97 + "version": "1.2.0"
  98 +}
  1 +Hi, figured we could actually use a changelog now:
  2 +
  3 +## 1.1.4 2017-04-21
  4 +
  5 +* Fix typo in package.json
  6 +
  7 +## 1.1.3 2017-04-21
  8 +
  9 +* Improve documentation and limit files included in the distribution.
  10 +
  11 +## 1.1.2 2016-03-15
  12 +
  13 +* Add tracker group cycle detection and tests for it
  14 +
  15 +## 1.1.1 2016-01-29
  16 +
  17 +* Fix a typo in stream completion tracker
  18 +
  19 +## 1.1.0 2016-01-29
  20 +
  21 +* Rewrote completion percent computation to be low impact– no more walking a
  22 + tree of completion groups every time we need this info. Previously, with
  23 + medium sized tree of completion groups, even a relatively modest number of
  24 + calls to the top level `completed()` method would result in absurd numbers
  25 + of calls overall as it walked down the tree. We now, instead, keep track as
  26 + we bubble up changes, so the computation is limited to when data changes and
  27 + to the depth of that one branch, instead of _every_ node. (Plus, we were already
  28 + incurring _this_ cost, since we already bubbled out changes.)
  29 +* Moved different tracker types out to their own files.
  30 +* Made tests test for TOO MANY events too.
  31 +* Standarized the source code formatting
  1 +Copyright (c) 2015, Rebecca Turner
  2 +
  3 +Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
  4 +
  5 +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  1 +are-we-there-yet
  2 +----------------
  3 +
  4 +Track complex hiearchies of asynchronous task completion statuses. This is
  5 +intended to give you a way of recording and reporting the progress of the big
  6 +recursive fan-out and gather type workflows that are so common in async.
  7 +
  8 +What you do with this completion data is up to you, but the most common use case is to
  9 +feed it to one of the many progress bar modules.
  10 +
  11 +Most progress bar modules include a rudamentary version of this, but my
  12 +needs were more complex.
  13 +
  14 +Usage
  15 +=====
  16 +
  17 +```javascript
  18 +var TrackerGroup = require("are-we-there-yet").TrackerGroup
  19 +
  20 +var top = new TrackerGroup("program")
  21 +
  22 +var single = top.newItem("one thing", 100)
  23 +single.completeWork(20)
  24 +
  25 +console.log(top.completed()) // 0.2
  26 +
  27 +fs.stat("file", function(er, stat) {
  28 + if (er) throw er
  29 + var stream = top.newStream("file", stat.size)
  30 + console.log(top.completed()) // now 0.1 as single is 50% of the job and is 20% complete
  31 + // and 50% * 20% == 10%
  32 + fs.createReadStream("file").pipe(stream).on("data", function (chunk) {
  33 + // do stuff with chunk
  34 + })
  35 + top.on("change", function (name) {
  36 + // called each time a chunk is read from "file"
  37 + // top.completed() will start at 0.1 and fill up to 0.6 as the file is read
  38 + })
  39 +})
  40 +```
  41 +
  42 +Shared Methods
  43 +==============
  44 +
  45 +* var completed = tracker.completed()
  46 +
  47 +Implemented in: `Tracker`, `TrackerGroup`, `TrackerStream`
  48 +
  49 +Returns the ratio of completed work to work to be done. Range of 0 to 1.
  50 +
  51 +* tracker.finish()
  52 +
  53 +Implemented in: `Tracker`, `TrackerGroup`
  54 +
  55 +Marks the tracker as completed. With a TrackerGroup this marks all of its
  56 +components as completed.
  57 +
  58 +Marks all of the components of this tracker as finished, which in turn means
  59 +that `tracker.completed()` for this will now be 1.
  60 +
  61 +This will result in one or more `change` events being emitted.
  62 +
  63 +Events
  64 +======
  65 +
  66 +All tracker objects emit `change` events with the following arguments:
  67 +
  68 +```
  69 +function (name, completed, tracker)
  70 +```
  71 +
  72 +`name` is the name of the tracker that originally emitted the event,
  73 +or if it didn't have one, the first containing tracker group that had one.
  74 +
  75 +`completed` is the percent complete (as returned by `tracker.completed()` method).
  76 +
  77 +`tracker` is the tracker object that you are listening for events on.
  78 +
  79 +TrackerGroup
  80 +============
  81 +
  82 +* var tracker = new TrackerGroup(**name**)
  83 +
  84 + * **name** *(optional)* - The name of this tracker group, used in change
  85 + notifications if the component updating didn't have a name. Defaults to undefined.
  86 +
  87 +Creates a new empty tracker aggregation group. These are trackers whose
  88 +completion status is determined by the completion status of other trackers.
  89 +
  90 +* tracker.addUnit(**otherTracker**, **weight**)
  91 +
  92 + * **otherTracker** - Any of the other are-we-there-yet tracker objects
  93 + * **weight** *(optional)* - The weight to give the tracker, defaults to 1.
  94 +
  95 +Adds the **otherTracker** to this aggregation group. The weight determines
  96 +how long you expect this tracker to take to complete in proportion to other
  97 +units. So for instance, if you add one tracker with a weight of 1 and
  98 +another with a weight of 2, you're saying the second will take twice as long
  99 +to complete as the first. As such, the first will account for 33% of the
  100 +completion of this tracker and the second will account for the other 67%.
  101 +
  102 +Returns **otherTracker**.
  103 +
  104 +* var subGroup = tracker.newGroup(**name**, **weight**)
  105 +
  106 +The above is exactly equivalent to:
  107 +
  108 +```javascript
  109 + var subGroup = tracker.addUnit(new TrackerGroup(name), weight)
  110 +```
  111 +
  112 +* var subItem = tracker.newItem(**name**, **todo**, **weight**)
  113 +
  114 +The above is exactly equivalent to:
  115 +
  116 +```javascript
  117 + var subItem = tracker.addUnit(new Tracker(name, todo), weight)
  118 +```
  119 +
  120 +* var subStream = tracker.newStream(**name**, **todo**, **weight**)
  121 +
  122 +The above is exactly equivalent to:
  123 +
  124 +```javascript
  125 + var subStream = tracker.addUnit(new TrackerStream(name, todo), weight)
  126 +```
  127 +
  128 +* console.log( tracker.debug() )
  129 +
  130 +Returns a tree showing the completion of this tracker group and all of its
  131 +children, including recursively entering all of the children.
  132 +
  133 +Tracker
  134 +=======
  135 +
  136 +* var tracker = new Tracker(**name**, **todo**)
  137 +
  138 + * **name** *(optional)* The name of this counter to report in change
  139 + events. Defaults to undefined.
  140 + * **todo** *(optional)* The amount of work todo (a number). Defaults to 0.
  141 +
  142 +Ordinarily these are constructed as a part of a tracker group (via
  143 +`newItem`).
  144 +
  145 +* var completed = tracker.completed()
  146 +
  147 +Returns the ratio of completed work to work to be done. Range of 0 to 1. If
  148 +total work to be done is 0 then it will return 0.
  149 +
  150 +* tracker.addWork(**todo**)
  151 +
  152 + * **todo** A number to add to the amount of work to be done.
  153 +
  154 +Increases the amount of work to be done, thus decreasing the completion
  155 +percentage. Triggers a `change` event.
  156 +
  157 +* tracker.completeWork(**completed**)
  158 +
  159 + * **completed** A number to add to the work complete
  160 +
  161 +Increase the amount of work complete, thus increasing the completion percentage.
  162 +Will never increase the work completed past the amount of work todo. That is,
  163 +percentages > 100% are not allowed. Triggers a `change` event.
  164 +
  165 +* tracker.finish()
  166 +
  167 +Marks this tracker as finished, tracker.completed() will now be 1. Triggers
  168 +a `change` event.
  169 +
  170 +TrackerStream
  171 +=============
  172 +
  173 +* var tracker = new TrackerStream(**name**, **size**, **options**)
  174 +
  175 + * **name** *(optional)* The name of this counter to report in change
  176 + events. Defaults to undefined.
  177 + * **size** *(optional)* The number of bytes being sent through this stream.
  178 + * **options** *(optional)* A hash of stream options
  179 +
  180 +The tracker stream object is a pass through stream that updates an internal
  181 +tracker object each time a block passes through. It's intended to track
  182 +downloads, file extraction and other related activities. You use it by piping
  183 +your data source into it and then using it as your data source.
  184 +
  185 +If your data has a length attribute then that's used as the amount of work
  186 +completed when the chunk is passed through. If it does not (eg, object
  187 +streams) then each chunk counts as completing 1 unit of work, so your size
  188 +should be the total number of objects being streamed.
  189 +
  190 +* tracker.addWork(**todo**)
  191 +
  192 + * **todo** Increase the expected overall size by **todo** bytes.
  193 +
  194 +Increases the amount of work to be done, thus decreasing the completion
  195 +percentage. Triggers a `change` event.
  1 +'use strict'
  2 +exports.TrackerGroup = require('./tracker-group.js')
  3 +exports.Tracker = require('./tracker.js')
  4 +exports.TrackerStream = require('./tracker-stream.js')
  1 +{
  2 + "_args": [
  3 + [
  4 + {
  5 + "raw": "are-we-there-yet@~1.1.2",
  6 + "scope": null,
  7 + "escapedName": "are-we-there-yet",
  8 + "name": "are-we-there-yet",
  9 + "rawSpec": "~1.1.2",
  10 + "spec": ">=1.1.2 <1.2.0",
  11 + "type": "range"
  12 + },
  13 + "/Users/fzy/project/koa2_Sequelize_project/node_modules/npmlog"
  14 + ]
  15 + ],
  16 + "_from": "are-we-there-yet@>=1.1.2 <1.2.0",
  17 + "_id": "are-we-there-yet@1.1.4",
  18 + "_inCache": true,
  19 + "_location": "/are-we-there-yet",
  20 + "_nodeVersion": "7.7.4",
  21 + "_npmOperationalInternal": {
  22 + "host": "packages-18-east.internal.npmjs.com",
  23 + "tmp": "tmp/are-we-there-yet-1.1.4.tgz_1492760790532_0.2543606413528323"
  24 + },
  25 + "_npmUser": {
  26 + "name": "iarna",
  27 + "email": "me@re-becca.org"
  28 + },
  29 + "_npmVersion": "4.5.0",
  30 + "_phantomChildren": {},
  31 + "_requested": {
  32 + "raw": "are-we-there-yet@~1.1.2",
  33 + "scope": null,
  34 + "escapedName": "are-we-there-yet",
  35 + "name": "are-we-there-yet",
  36 + "rawSpec": "~1.1.2",
  37 + "spec": ">=1.1.2 <1.2.0",
  38 + "type": "range"
  39 + },
  40 + "_requiredBy": [
  41 + "/npmlog"
  42 + ],
  43 + "_resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.4.tgz",
  44 + "_shasum": "bb5dca382bb94f05e15194373d16fd3ba1ca110d",
  45 + "_shrinkwrap": null,
  46 + "_spec": "are-we-there-yet@~1.1.2",
  47 + "_where": "/Users/fzy/project/koa2_Sequelize_project/node_modules/npmlog",
  48 + "author": {
  49 + "name": "Rebecca Turner",
  50 + "url": "http://re-becca.org"
  51 + },
  52 + "bugs": {
  53 + "url": "https://github.com/iarna/are-we-there-yet/issues"
  54 + },
  55 + "dependencies": {
  56 + "delegates": "^1.0.0",
  57 + "readable-stream": "^2.0.6"
  58 + },
  59 + "description": "Keep track of the overall completion of many disparate processes",
  60 + "devDependencies": {
  61 + "standard": "^6.0.8",
  62 + "tap": "^5.7.0"
  63 + },
  64 + "directories": {},
  65 + "dist": {
  66 + "shasum": "bb5dca382bb94f05e15194373d16fd3ba1ca110d",
  67 + "tarball": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.4.tgz"
  68 + },
  69 + "files": [
  70 + "index.js",
  71 + "tracker-base.js",
  72 + "tracker-group.js",
  73 + "tracker-stream.js",
  74 + "tracker.js",
  75 + "CHANGES.md"
  76 + ],
  77 + "gitHead": "aea89b9c277c0674a2485a3eb94a7269bb2346be",
  78 + "homepage": "https://github.com/iarna/are-we-there-yet",
  79 + "license": "ISC",
  80 + "main": "index.js",
  81 + "maintainers": [
  82 + {
  83 + "name": "iarna",
  84 + "email": "me@re-becca.org"
  85 + }
  86 + ],
  87 + "name": "are-we-there-yet",
  88 + "optionalDependencies": {},
  89 + "readme": "are-we-there-yet\n----------------\n\nTrack complex hiearchies of asynchronous task completion statuses. This is\nintended to give you a way of recording and reporting the progress of the big\nrecursive fan-out and gather type workflows that are so common in async.\n\nWhat you do with this completion data is up to you, but the most common use case is to\nfeed it to one of the many progress bar modules.\n\nMost progress bar modules include a rudamentary version of this, but my\nneeds were more complex.\n\nUsage\n=====\n\n```javascript\nvar TrackerGroup = require(\"are-we-there-yet\").TrackerGroup\n\nvar top = new TrackerGroup(\"program\")\n\nvar single = top.newItem(\"one thing\", 100)\nsingle.completeWork(20)\n\nconsole.log(top.completed()) // 0.2\n\nfs.stat(\"file\", function(er, stat) {\n if (er) throw er \n var stream = top.newStream(\"file\", stat.size)\n console.log(top.completed()) // now 0.1 as single is 50% of the job and is 20% complete\n // and 50% * 20% == 10%\n fs.createReadStream(\"file\").pipe(stream).on(\"data\", function (chunk) {\n // do stuff with chunk\n })\n top.on(\"change\", function (name) {\n // called each time a chunk is read from \"file\"\n // top.completed() will start at 0.1 and fill up to 0.6 as the file is read\n })\n})\n```\n\nShared Methods\n==============\n\n* var completed = tracker.completed()\n\nImplemented in: `Tracker`, `TrackerGroup`, `TrackerStream`\n\nReturns the ratio of completed work to work to be done. Range of 0 to 1.\n\n* tracker.finish()\n\nImplemented in: `Tracker`, `TrackerGroup`\n\nMarks the tracker as completed. With a TrackerGroup this marks all of its\ncomponents as completed.\n\nMarks all of the components of this tracker as finished, which in turn means\nthat `tracker.completed()` for this will now be 1.\n\nThis will result in one or more `change` events being emitted.\n\nEvents\n======\n\nAll tracker objects emit `change` events with the following arguments:\n\n```\nfunction (name, completed, tracker)\n```\n\n`name` is the name of the tracker that originally emitted the event,\nor if it didn't have one, the first containing tracker group that had one.\n\n`completed` is the percent complete (as returned by `tracker.completed()` method).\n\n`tracker` is the tracker object that you are listening for events on.\n\nTrackerGroup\n============\n\n* var tracker = new TrackerGroup(**name**)\n\n * **name** *(optional)* - The name of this tracker group, used in change\n notifications if the component updating didn't have a name. Defaults to undefined.\n\nCreates a new empty tracker aggregation group. These are trackers whose\ncompletion status is determined by the completion status of other trackers.\n\n* tracker.addUnit(**otherTracker**, **weight**)\n\n * **otherTracker** - Any of the other are-we-there-yet tracker objects\n * **weight** *(optional)* - The weight to give the tracker, defaults to 1.\n\nAdds the **otherTracker** to this aggregation group. The weight determines\nhow long you expect this tracker to take to complete in proportion to other\nunits. So for instance, if you add one tracker with a weight of 1 and\nanother with a weight of 2, you're saying the second will take twice as long\nto complete as the first. As such, the first will account for 33% of the\ncompletion of this tracker and the second will account for the other 67%.\n\nReturns **otherTracker**.\n\n* var subGroup = tracker.newGroup(**name**, **weight**)\n\nThe above is exactly equivalent to:\n\n```javascript\n var subGroup = tracker.addUnit(new TrackerGroup(name), weight)\n```\n\n* var subItem = tracker.newItem(**name**, **todo**, **weight**)\n\nThe above is exactly equivalent to:\n\n```javascript\n var subItem = tracker.addUnit(new Tracker(name, todo), weight)\n```\n\n* var subStream = tracker.newStream(**name**, **todo**, **weight**)\n\nThe above is exactly equivalent to:\n\n```javascript\n var subStream = tracker.addUnit(new TrackerStream(name, todo), weight)\n```\n\n* console.log( tracker.debug() )\n\nReturns a tree showing the completion of this tracker group and all of its\nchildren, including recursively entering all of the children.\n\nTracker\n=======\n\n* var tracker = new Tracker(**name**, **todo**)\n\n * **name** *(optional)* The name of this counter to report in change\n events. Defaults to undefined.\n * **todo** *(optional)* The amount of work todo (a number). Defaults to 0.\n\nOrdinarily these are constructed as a part of a tracker group (via\n`newItem`).\n\n* var completed = tracker.completed()\n\nReturns the ratio of completed work to work to be done. Range of 0 to 1. If\ntotal work to be done is 0 then it will return 0.\n\n* tracker.addWork(**todo**)\n\n * **todo** A number to add to the amount of work to be done.\n\nIncreases the amount of work to be done, thus decreasing the completion\npercentage. Triggers a `change` event.\n\n* tracker.completeWork(**completed**)\n\n * **completed** A number to add to the work complete\n\nIncrease the amount of work complete, thus increasing the completion percentage.\nWill never increase the work completed past the amount of work todo. That is,\npercentages > 100% are not allowed. Triggers a `change` event.\n\n* tracker.finish()\n\nMarks this tracker as finished, tracker.completed() will now be 1. Triggers\na `change` event.\n\nTrackerStream\n=============\n\n* var tracker = new TrackerStream(**name**, **size**, **options**)\n\n * **name** *(optional)* The name of this counter to report in change\n events. Defaults to undefined.\n * **size** *(optional)* The number of bytes being sent through this stream.\n * **options** *(optional)* A hash of stream options\n\nThe tracker stream object is a pass through stream that updates an internal\ntracker object each time a block passes through. It's intended to track\ndownloads, file extraction and other related activities. You use it by piping\nyour data source into it and then using it as your data source.\n\nIf your data has a length attribute then that's used as the amount of work\ncompleted when the chunk is passed through. If it does not (eg, object\nstreams) then each chunk counts as completing 1 unit of work, so your size\nshould be the total number of objects being streamed.\n\n* tracker.addWork(**todo**)\n\n * **todo** Increase the expected overall size by **todo** bytes.\n\nIncreases the amount of work to be done, thus decreasing the completion\npercentage. Triggers a `change` event.\n",
  90 + "readmeFilename": "README.md",
  91 + "repository": {
  92 + "type": "git",
  93 + "url": "git+https://github.com/iarna/are-we-there-yet.git"
  94 + },
  95 + "scripts": {
  96 + "test": "standard && tap test/*.js"
  97 + },
  98 + "version": "1.1.4"
  99 +}
  1 +'use strict'
  2 +var EventEmitter = require('events').EventEmitter
  3 +var util = require('util')
  4 +
  5 +var trackerId = 0
  6 +var TrackerBase = module.exports = function (name) {
  7 + EventEmitter.call(this)
  8 + this.id = ++trackerId
  9 + this.name = name
  10 +}
  11 +util.inherits(TrackerBase, EventEmitter)
  1 +'use strict'
  2 +var util = require('util')
  3 +var TrackerBase = require('./tracker-base.js')
  4 +var Tracker = require('./tracker.js')
  5 +var TrackerStream = require('./tracker-stream.js')
  6 +
  7 +var TrackerGroup = module.exports = function (name) {
  8 + TrackerBase.call(this, name)
  9 + this.parentGroup = null
  10 + this.trackers = []
  11 + this.completion = {}
  12 + this.weight = {}
  13 + this.totalWeight = 0
  14 + this.finished = false
  15 + this.bubbleChange = bubbleChange(this)
  16 +}
  17 +util.inherits(TrackerGroup, TrackerBase)
  18 +
  19 +function bubbleChange (trackerGroup) {
  20 + return function (name, completed, tracker) {
  21 + trackerGroup.completion[tracker.id] = completed
  22 + if (trackerGroup.finished) return
  23 + trackerGroup.emit('change', name || trackerGroup.name, trackerGroup.completed(), trackerGroup)
  24 + }
  25 +}
  26 +
  27 +TrackerGroup.prototype.nameInTree = function () {
  28 + var names = []
  29 + var from = this
  30 + while (from) {
  31 + names.unshift(from.name)
  32 + from = from.parentGroup
  33 + }
  34 + return names.join('/')
  35 +}
  36 +
  37 +TrackerGroup.prototype.addUnit = function (unit, weight) {
  38 + if (unit.addUnit) {
  39 + var toTest = this
  40 + while (toTest) {
  41 + if (unit === toTest) {
  42 + throw new Error(
  43 + 'Attempted to add tracker group ' +
  44 + unit.name + ' to tree that already includes it ' +
  45 + this.nameInTree(this))
  46 + }
  47 + toTest = toTest.parentGroup
  48 + }
  49 + unit.parentGroup = this
  50 + }
  51 + this.weight[unit.id] = weight || 1
  52 + this.totalWeight += this.weight[unit.id]
  53 + this.trackers.push(unit)
  54 + this.completion[unit.id] = unit.completed()
  55 + unit.on('change', this.bubbleChange)
  56 + if (!this.finished) this.emit('change', unit.name, this.completion[unit.id], unit)
  57 + return unit
  58 +}
  59 +
  60 +TrackerGroup.prototype.completed = function () {
  61 + if (this.trackers.length === 0) return 0
  62 + var valPerWeight = 1 / this.totalWeight
  63 + var completed = 0
  64 + for (var ii = 0; ii < this.trackers.length; ii++) {
  65 + var trackerId = this.trackers[ii].id
  66 + completed += valPerWeight * this.weight[trackerId] * this.completion[trackerId]
  67 + }
  68 + return completed
  69 +}
  70 +
  71 +TrackerGroup.prototype.newGroup = function (name, weight) {
  72 + return this.addUnit(new TrackerGroup(name), weight)
  73 +}
  74 +
  75 +TrackerGroup.prototype.newItem = function (name, todo, weight) {
  76 + return this.addUnit(new Tracker(name, todo), weight)
  77 +}
  78 +
  79 +TrackerGroup.prototype.newStream = function (name, todo, weight) {
  80 + return this.addUnit(new TrackerStream(name, todo), weight)
  81 +}
  82 +
  83 +TrackerGroup.prototype.finish = function () {
  84 + this.finished = true
  85 + if (!this.trackers.length) this.addUnit(new Tracker(), 1, true)
  86 + for (var ii = 0; ii < this.trackers.length; ii++) {
  87 + var tracker = this.trackers[ii]
  88 + tracker.finish()
  89 + tracker.removeListener('change', this.bubbleChange)
  90 + }
  91 + this.emit('change', this.name, 1, this)
  92 +}
  93 +
  94 +var buffer = ' '
  95 +TrackerGroup.prototype.debug = function (depth) {
  96 + depth = depth || 0
  97 + var indent = depth ? buffer.substr(0, depth) : ''
  98 + var output = indent + (this.name || 'top') + ': ' + this.completed() + '\n'
  99 + this.trackers.forEach(function (tracker) {
  100 + if (tracker instanceof TrackerGroup) {
  101 + output += tracker.debug(depth + 1)
  102 + } else {
  103 + output += indent + ' ' + tracker.name + ': ' + tracker.completed() + '\n'
  104 + }
  105 + })
  106 + return output
  107 +}
  1 +'use strict'
  2 +var util = require('util')
  3 +var stream = require('readable-stream')
  4 +var delegate = require('delegates')
  5 +var Tracker = require('./tracker.js')
  6 +
  7 +var TrackerStream = module.exports = function (name, size, options) {
  8 + stream.Transform.call(this, options)
  9 + this.tracker = new Tracker(name, size)
  10 + this.name = name
  11 + this.id = this.tracker.id
  12 + this.tracker.on('change', delegateChange(this))
  13 +}
  14 +util.inherits(TrackerStream, stream.Transform)
  15 +
  16 +function delegateChange (trackerStream) {
  17 + return function (name, completion, tracker) {
  18 + trackerStream.emit('change', name, completion, trackerStream)
  19 + }
  20 +}
  21 +
  22 +TrackerStream.prototype._transform = function (data, encoding, cb) {
  23 + this.tracker.completeWork(data.length ? data.length : 1)
  24 + this.push(data)
  25 + cb()
  26 +}
  27 +
  28 +TrackerStream.prototype._flush = function (cb) {
  29 + this.tracker.finish()
  30 + cb()
  31 +}
  32 +
  33 +delegate(TrackerStream.prototype, 'tracker')
  34 + .method('completed')
  35 + .method('addWork')
  1 +'use strict'
  2 +var util = require('util')
  3 +var TrackerBase = require('./tracker-base.js')
  4 +
  5 +var Tracker = module.exports = function (name, todo) {
  6 + TrackerBase.call(this, name)
  7 + this.workDone = 0
  8 + this.workTodo = todo || 0
  9 +}
  10 +util.inherits(Tracker, TrackerBase)
  11 +
  12 +Tracker.prototype.completed = function () {
  13 + return this.workTodo === 0 ? 0 : this.workDone / this.workTodo
  14 +}
  15 +
  16 +Tracker.prototype.addWork = function (work) {
  17 + this.workTodo += work
  18 + this.emit('change', this.name, this.completed(), this)
  19 +}
  20 +
  21 +Tracker.prototype.completeWork = function (work) {
  22 + this.workDone += work
  23 + if (this.workDone > this.workTodo) this.workDone = this.workTodo
  24 + this.emit('change', this.name, this.completed(), this)
  25 +}
  26 +
  27 +Tracker.prototype.finish = function () {
  28 + this.workTodo = this.workDone = 1
  29 + this.emit('change', this.name, 1, this)
  30 +}
  1 +language: node_js
  2 +before_install:
  3 + - npm install -g npm@2
  4 + - npm install -g npm
  5 +matrix:
  6 + include:
  7 + - node_js: '0.8'
  8 + env: TASK=test-node
  9 + - node_js: '0.10'
  10 + env: TASK=test-node
  11 + - node_js: '0.11'
  12 + env: TASK=test-node
  13 + - node_js: '0.12'
  14 + env: TASK=test-node
  15 + - node_js: 1
  16 + env: TASK=test-node
  17 + - node_js: 2
  18 + env: TASK=test-node
  19 + - node_js: 3
  20 + env: TASK=test-node
  21 + - node_js: 4
  22 + env: TASK=test-node
  23 + - node_js: 5
  24 + env: TASK=test-node
  25 + - node_js: '0.10'
  26 + env: TASK=test-browser
  27 +script: "npm run $TASK"
  28 +env:
  29 + global:
  30 + - secure: qThuKBZQtkooAvzaYldECGNqvKGPRTnXx62IVyhSbFlsCY1VCmjhLldhyPDiZQ3JqL1XvSkK8OMDupiHqZnNE0nGijoO4M/kaEdjBB+jpjg3f8I6te2SNU935SbkfY9KHAaFXMZwdcq7Fk932AxWEu+FMSDM+080wNKpEATXDe4=
  31 + - secure: O/scKjHLRcPN5ILV5qsSkksQ7qcZQdHWEUUPItmj/4+vmCc28bHpicoUxXG5A96iHvkBbdmky/nGCg464ZaNLk68m6hfEMDAR3J6mhM2Pf5C4QI/LlFlR1fob9sQ8lztwSGOItwdK8Rfrgb30RRVV71f6FxnaJ6PKMuMNT5S1AQ=
  1 +ui: mocha-qunit
  2 +tunnel: ngrok
  3 +browsers:
  4 + - name: chrome
  5 + version: latest
  6 + - name: firefox
  7 + version: latest
  8 + - name: safari
  9 + version: latest
  10 + - name: ie
  11 + version: 9..latest
  12 + - name: microsoftedge
  13 + version: latest
  1 +Copyright Joyent, Inc. and other Node contributors. All rights reserved.
  2 +Permission is hereby granted, free of charge, to any person obtaining a copy
  3 +of this software and associated documentation files (the "Software"), to
  4 +deal in the Software without restriction, including without limitation the
  5 +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  6 +sell copies of the Software, and to permit persons to whom the Software is
  7 +furnished to do so, subject to the following conditions:
  8 +
  9 +The above copyright notice and this permission notice shall be included in
  10 +all copies or substantial portions of the Software.
  11 +
  12 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  17 +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  18 +IN THE SOFTWARE.
  1 +# assert
  2 +
  3 +[![Build Status](https://travis-ci.org/defunctzombie/commonjs-assert.svg?branch=master)](https://travis-ci.org/defunctzombie/commonjs-assert)
  4 +
  5 +This module is used for writing unit tests for your applications, you can access it with require('assert').
  6 +
  7 +The API is derived from the [commonjs 1.0 unit testing](http://wiki.commonjs.org/wiki/Unit_Testing/1.0) spec and the [node.js assert module](http://nodejs.org/api/assert.html)
  8 +
  9 +## assert.fail(actual, expected, message, operator)
  10 +Throws an exception that displays the values for actual and expected separated by the provided operator.
  11 +
  12 +## assert(value, message), assert.ok(value, [message])
  13 +Tests if value is truthy, it is equivalent to assert.equal(true, !!value, message);
  14 +
  15 +## assert.equal(actual, expected, [message])
  16 +Tests shallow, coercive equality with the equal comparison operator ( == ).
  17 +
  18 +## assert.notEqual(actual, expected, [message])
  19 +Tests shallow, coercive non-equality with the not equal comparison operator ( != ).
  20 +
  21 +## assert.deepEqual(actual, expected, [message])
  22 +Tests for deep equality.
  23 +
  24 +## assert.notDeepEqual(actual, expected, [message])
  25 +Tests for any deep inequality.
  26 +
  27 +## assert.strictEqual(actual, expected, [message])
  28 +Tests strict equality, as determined by the strict equality operator ( === )
  29 +
  30 +## assert.notStrictEqual(actual, expected, [message])
  31 +Tests strict non-equality, as determined by the strict not equal operator ( !== )
  32 +
  33 +## assert.throws(block, [error], [message])
  34 +Expects block to throw an error. error can be constructor, regexp or validation function.
  35 +
  36 +Validate instanceof using constructor:
  37 +
  38 +```javascript
  39 +assert.throws(function() { throw new Error("Wrong value"); }, Error);
  40 +```
  41 +
  42 +Validate error message using RegExp:
  43 +
  44 +```javascript
  45 +assert.throws(function() { throw new Error("Wrong value"); }, /value/);
  46 +```
  47 +
  48 +Custom error validation:
  49 +
  50 +```javascript
  51 +assert.throws(function() {
  52 + throw new Error("Wrong value");
  53 +}, function(err) {
  54 + if ( (err instanceof Error) && /value/.test(err) ) {
  55 + return true;
  56 + }
  57 +}, "unexpected error");
  58 +```
  59 +
  60 +## assert.doesNotThrow(block, [message])
  61 +Expects block not to throw an error, see assert.throws for details.
  62 +
  63 +## assert.ifError(value)
  64 +Tests if value is not a false value, throws if it is a true value. Useful when testing the first argument, error in callbacks.
  1 +'use strict';
  2 +
  3 +// compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js
  4 +// original notice:
  5 +
  6 +/*!
  7 + * The buffer module from node.js, for the browser.
  8 + *
  9 + * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  10 + * @license MIT
  11 + */
  12 +function compare(a, b) {
  13 + if (a === b) {
  14 + return 0;
  15 + }
  16 +
  17 + var x = a.length;
  18 + var y = b.length;
  19 +
  20 + for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  21 + if (a[i] !== b[i]) {
  22 + x = a[i];
  23 + y = b[i];
  24 + break;
  25 + }
  26 + }
  27 +
  28 + if (x < y) {
  29 + return -1;
  30 + }
  31 + if (y < x) {
  32 + return 1;
  33 + }
  34 + return 0;
  35 +}
  36 +function isBuffer(b) {
  37 + if (global.Buffer && typeof global.Buffer.isBuffer === 'function') {
  38 + return global.Buffer.isBuffer(b);
  39 + }
  40 + return !!(b != null && b._isBuffer);
  41 +}
  42 +
  43 +// based on node assert, original notice:
  44 +
  45 +// http://wiki.commonjs.org/wiki/Unit_Testing/1.0
  46 +//
  47 +// THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
  48 +//
  49 +// Originally from narwhal.js (http://narwhaljs.org)
  50 +// Copyright (c) 2009 Thomas Robinson <280north.com>
  51 +//
  52 +// Permission is hereby granted, free of charge, to any person obtaining a copy
  53 +// of this software and associated documentation files (the 'Software'), to
  54 +// deal in the Software without restriction, including without limitation the
  55 +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  56 +// sell copies of the Software, and to permit persons to whom the Software is
  57 +// furnished to do so, subject to the following conditions:
  58 +//
  59 +// The above copyright notice and this permission notice shall be included in
  60 +// all copies or substantial portions of the Software.
  61 +//
  62 +// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  63 +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  64 +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  65 +// AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  66 +// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  67 +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  68 +
  69 +var util = require('util/');
  70 +var hasOwn = Object.prototype.hasOwnProperty;
  71 +var pSlice = Array.prototype.slice;
  72 +var functionsHaveNames = (function () {
  73 + return function foo() {}.name === 'foo';
  74 +}());
  75 +function pToString (obj) {
  76 + return Object.prototype.toString.call(obj);
  77 +}
  78 +function isView(arrbuf) {
  79 + if (isBuffer(arrbuf)) {
  80 + return false;
  81 + }
  82 + if (typeof global.ArrayBuffer !== 'function') {
  83 + return false;
  84 + }
  85 + if (typeof ArrayBuffer.isView === 'function') {
  86 + return ArrayBuffer.isView(arrbuf);
  87 + }
  88 + if (!arrbuf) {
  89 + return false;
  90 + }
  91 + if (arrbuf instanceof DataView) {
  92 + return true;
  93 + }
  94 + if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) {
  95 + return true;
  96 + }
  97 + return false;
  98 +}
  99 +// 1. The assert module provides functions that throw
  100 +// AssertionError's when particular conditions are not met. The
  101 +// assert module must conform to the following interface.
  102 +
  103 +var assert = module.exports = ok;
  104 +
  105 +// 2. The AssertionError is defined in assert.
  106 +// new assert.AssertionError({ message: message,
  107 +// actual: actual,
  108 +// expected: expected })
  109 +
  110 +var regex = /\s*function\s+([^\(\s]*)\s*/;
  111 +// based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js
  112 +function getName(func) {
  113 + if (!util.isFunction(func)) {
  114 + return;
  115 + }
  116 + if (functionsHaveNames) {
  117 + return func.name;
  118 + }
  119 + var str = func.toString();
  120 + var match = str.match(regex);
  121 + return match && match[1];
  122 +}
  123 +assert.AssertionError = function AssertionError(options) {
  124 + this.name = 'AssertionError';
  125 + this.actual = options.actual;
  126 + this.expected = options.expected;
  127 + this.operator = options.operator;
  128 + if (options.message) {
  129 + this.message = options.message;
  130 + this.generatedMessage = false;
  131 + } else {
  132 + this.message = getMessage(this);
  133 + this.generatedMessage = true;
  134 + }
  135 + var stackStartFunction = options.stackStartFunction || fail;
  136 + if (Error.captureStackTrace) {
  137 + Error.captureStackTrace(this, stackStartFunction);
  138 + } else {
  139 + // non v8 browsers so we can have a stacktrace
  140 + var err = new Error();
  141 + if (err.stack) {
  142 + var out = err.stack;
  143 +
  144 + // try to strip useless frames
  145 + var fn_name = getName(stackStartFunction);
  146 + var idx = out.indexOf('\n' + fn_name);
  147 + if (idx >= 0) {
  148 + // once we have located the function frame
  149 + // we need to strip out everything before it (and its line)
  150 + var next_line = out.indexOf('\n', idx + 1);
  151 + out = out.substring(next_line + 1);
  152 + }
  153 +
  154 + this.stack = out;
  155 + }
  156 + }
  157 +};
  158 +
  159 +// assert.AssertionError instanceof Error
  160 +util.inherits(assert.AssertionError, Error);
  161 +
  162 +function truncate(s, n) {
  163 + if (typeof s === 'string') {
  164 + return s.length < n ? s : s.slice(0, n);
  165 + } else {
  166 + return s;
  167 + }
  168 +}
  169 +function inspect(something) {
  170 + if (functionsHaveNames || !util.isFunction(something)) {
  171 + return util.inspect(something);
  172 + }
  173 + var rawname = getName(something);
  174 + var name = rawname ? ': ' + rawname : '';
  175 + return '[Function' + name + ']';
  176 +}
  177 +function getMessage(self) {
  178 + return truncate(inspect(self.actual), 128) + ' ' +
  179 + self.operator + ' ' +
  180 + truncate(inspect(self.expected), 128);
  181 +}
  182 +
  183 +// At present only the three keys mentioned above are used and
  184 +// understood by the spec. Implementations or sub modules can pass
  185 +// other keys to the AssertionError's constructor - they will be
  186 +// ignored.
  187 +
  188 +// 3. All of the following functions must throw an AssertionError
  189 +// when a corresponding condition is not met, with a message that
  190 +// may be undefined if not provided. All assertion methods provide
  191 +// both the actual and expected values to the assertion error for
  192 +// display purposes.
  193 +
  194 +function fail(actual, expected, message, operator, stackStartFunction) {
  195 + throw new assert.AssertionError({
  196 + message: message,
  197 + actual: actual,
  198 + expected: expected,
  199 + operator: operator,
  200 + stackStartFunction: stackStartFunction
  201 + });
  202 +}
  203 +
  204 +// EXTENSION! allows for well behaved errors defined elsewhere.
  205 +assert.fail = fail;
  206 +
  207 +// 4. Pure assertion tests whether a value is truthy, as determined
  208 +// by !!guard.
  209 +// assert.ok(guard, message_opt);
  210 +// This statement is equivalent to assert.equal(true, !!guard,
  211 +// message_opt);. To test strictly for the value true, use
  212 +// assert.strictEqual(true, guard, message_opt);.
  213 +
  214 +function ok(value, message) {
  215 + if (!value) fail(value, true, message, '==', assert.ok);
  216 +}
  217 +assert.ok = ok;
  218 +
  219 +// 5. The equality assertion tests shallow, coercive equality with
  220 +// ==.
  221 +// assert.equal(actual, expected, message_opt);
  222 +
  223 +assert.equal = function equal(actual, expected, message) {
  224 + if (actual != expected) fail(actual, expected, message, '==', assert.equal);
  225 +};
  226 +
  227 +// 6. The non-equality assertion tests for whether two objects are not equal
  228 +// with != assert.notEqual(actual, expected, message_opt);
  229 +
  230 +assert.notEqual = function notEqual(actual, expected, message) {
  231 + if (actual == expected) {
  232 + fail(actual, expected, message, '!=', assert.notEqual);
  233 + }
  234 +};
  235 +
  236 +// 7. The equivalence assertion tests a deep equality relation.
  237 +// assert.deepEqual(actual, expected, message_opt);
  238 +
  239 +assert.deepEqual = function deepEqual(actual, expected, message) {
  240 + if (!_deepEqual(actual, expected, false)) {
  241 + fail(actual, expected, message, 'deepEqual', assert.deepEqual);
  242 + }
  243 +};
  244 +
  245 +assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) {
  246 + if (!_deepEqual(actual, expected, true)) {
  247 + fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual);
  248 + }
  249 +};
  250 +
  251 +function _deepEqual(actual, expected, strict, memos) {
  252 + // 7.1. All identical values are equivalent, as determined by ===.
  253 + if (actual === expected) {
  254 + return true;
  255 + } else if (isBuffer(actual) && isBuffer(expected)) {
  256 + return compare(actual, expected) === 0;
  257 +
  258 + // 7.2. If the expected value is a Date object, the actual value is
  259 + // equivalent if it is also a Date object that refers to the same time.
  260 + } else if (util.isDate(actual) && util.isDate(expected)) {
  261 + return actual.getTime() === expected.getTime();
  262 +
  263 + // 7.3 If the expected value is a RegExp object, the actual value is
  264 + // equivalent if it is also a RegExp object with the same source and
  265 + // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
  266 + } else if (util.isRegExp(actual) && util.isRegExp(expected)) {
  267 + return actual.source === expected.source &&
  268 + actual.global === expected.global &&
  269 + actual.multiline === expected.multiline &&
  270 + actual.lastIndex === expected.lastIndex &&
  271 + actual.ignoreCase === expected.ignoreCase;
  272 +
  273 + // 7.4. Other pairs that do not both pass typeof value == 'object',
  274 + // equivalence is determined by ==.
  275 + } else if ((actual === null || typeof actual !== 'object') &&
  276 + (expected === null || typeof expected !== 'object')) {
  277 + return strict ? actual === expected : actual == expected;
  278 +
  279 + // If both values are instances of typed arrays, wrap their underlying
  280 + // ArrayBuffers in a Buffer each to increase performance
  281 + // This optimization requires the arrays to have the same type as checked by
  282 + // Object.prototype.toString (aka pToString). Never perform binary
  283 + // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their
  284 + // bit patterns are not identical.
  285 + } else if (isView(actual) && isView(expected) &&
  286 + pToString(actual) === pToString(expected) &&
  287 + !(actual instanceof Float32Array ||
  288 + actual instanceof Float64Array)) {
  289 + return compare(new Uint8Array(actual.buffer),
  290 + new Uint8Array(expected.buffer)) === 0;
  291 +
  292 + // 7.5 For all other Object pairs, including Array objects, equivalence is
  293 + // determined by having the same number of owned properties (as verified
  294 + // with Object.prototype.hasOwnProperty.call), the same set of keys
  295 + // (although not necessarily the same order), equivalent values for every
  296 + // corresponding key, and an identical 'prototype' property. Note: this
  297 + // accounts for both named and indexed properties on Arrays.
  298 + } else if (isBuffer(actual) !== isBuffer(expected)) {
  299 + return false;
  300 + } else {
  301 + memos = memos || {actual: [], expected: []};
  302 +
  303 + var actualIndex = memos.actual.indexOf(actual);
  304 + if (actualIndex !== -1) {
  305 + if (actualIndex === memos.expected.indexOf(expected)) {
  306 + return true;
  307 + }
  308 + }
  309 +
  310 + memos.actual.push(actual);
  311 + memos.expected.push(expected);
  312 +
  313 + return objEquiv(actual, expected, strict, memos);
  314 + }
  315 +}
  316 +
  317 +function isArguments(object) {
  318 + return Object.prototype.toString.call(object) == '[object Arguments]';
  319 +}
  320 +
  321 +function objEquiv(a, b, strict, actualVisitedObjects) {
  322 + if (a === null || a === undefined || b === null || b === undefined)
  323 + return false;
  324 + // if one is a primitive, the other must be same
  325 + if (util.isPrimitive(a) || util.isPrimitive(b))
  326 + return a === b;
  327 + if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b))
  328 + return false;
  329 + var aIsArgs = isArguments(a);
  330 + var bIsArgs = isArguments(b);
  331 + if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
  332 + return false;
  333 + if (aIsArgs) {
  334 + a = pSlice.call(a);
  335 + b = pSlice.call(b);
  336 + return _deepEqual(a, b, strict);
  337 + }
  338 + var ka = objectKeys(a);
  339 + var kb = objectKeys(b);
  340 + var key, i;
  341 + // having the same number of owned properties (keys incorporates
  342 + // hasOwnProperty)
  343 + if (ka.length !== kb.length)
  344 + return false;
  345 + //the same set of keys (although not necessarily the same order),
  346 + ka.sort();
  347 + kb.sort();
  348 + //~~~cheap key test
  349 + for (i = ka.length - 1; i >= 0; i--) {
  350 + if (ka[i] !== kb[i])
  351 + return false;
  352 + }
  353 + //equivalent values for every corresponding key, and
  354 + //~~~possibly expensive deep test
  355 + for (i = ka.length - 1; i >= 0; i--) {
  356 + key = ka[i];
  357 + if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects))
  358 + return false;
  359 + }
  360 + return true;
  361 +}
  362 +
  363 +// 8. The non-equivalence assertion tests for any deep inequality.
  364 +// assert.notDeepEqual(actual, expected, message_opt);
  365 +
  366 +assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
  367 + if (_deepEqual(actual, expected, false)) {
  368 + fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
  369 + }
  370 +};
  371 +
  372 +assert.notDeepStrictEqual = notDeepStrictEqual;
  373 +function notDeepStrictEqual(actual, expected, message) {
  374 + if (_deepEqual(actual, expected, true)) {
  375 + fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual);
  376 + }
  377 +}
  378 +
  379 +
  380 +// 9. The strict equality assertion tests strict equality, as determined by ===.
  381 +// assert.strictEqual(actual, expected, message_opt);
  382 +
  383 +assert.strictEqual = function strictEqual(actual, expected, message) {
  384 + if (actual !== expected) {
  385 + fail(actual, expected, message, '===', assert.strictEqual);
  386 + }
  387 +};
  388 +
  389 +// 10. The strict non-equality assertion tests for strict inequality, as
  390 +// determined by !==. assert.notStrictEqual(actual, expected, message_opt);
  391 +
  392 +assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
  393 + if (actual === expected) {
  394 + fail(actual, expected, message, '!==', assert.notStrictEqual);
  395 + }
  396 +};
  397 +
  398 +function expectedException(actual, expected) {
  399 + if (!actual || !expected) {
  400 + return false;
  401 + }
  402 +
  403 + if (Object.prototype.toString.call(expected) == '[object RegExp]') {
  404 + return expected.test(actual);
  405 + }
  406 +
  407 + try {
  408 + if (actual instanceof expected) {
  409 + return true;
  410 + }
  411 + } catch (e) {
  412 + // Ignore. The instanceof check doesn't work for arrow functions.
  413 + }
  414 +
  415 + if (Error.isPrototypeOf(expected)) {
  416 + return false;
  417 + }
  418 +
  419 + return expected.call({}, actual) === true;
  420 +}
  421 +
  422 +function _tryBlock(block) {
  423 + var error;
  424 + try {
  425 + block();
  426 + } catch (e) {
  427 + error = e;
  428 + }
  429 + return error;
  430 +}
  431 +
  432 +function _throws(shouldThrow, block, expected, message) {
  433 + var actual;
  434 +
  435 + if (typeof block !== 'function') {
  436 + throw new TypeError('"block" argument must be a function');
  437 + }
  438 +
  439 + if (typeof expected === 'string') {
  440 + message = expected;
  441 + expected = null;
  442 + }
  443 +
  444 + actual = _tryBlock(block);
  445 +
  446 + message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
  447 + (message ? ' ' + message : '.');
  448 +
  449 + if (shouldThrow && !actual) {
  450 + fail(actual, expected, 'Missing expected exception' + message);
  451 + }
  452 +
  453 + var userProvidedMessage = typeof message === 'string';
  454 + var isUnwantedException = !shouldThrow && util.isError(actual);
  455 + var isUnexpectedException = !shouldThrow && actual && !expected;
  456 +
  457 + if ((isUnwantedException &&
  458 + userProvidedMessage &&
  459 + expectedException(actual, expected)) ||
  460 + isUnexpectedException) {
  461 + fail(actual, expected, 'Got unwanted exception' + message);
  462 + }
  463 +
  464 + if ((shouldThrow && actual && expected &&
  465 + !expectedException(actual, expected)) || (!shouldThrow && actual)) {
  466 + throw actual;
  467 + }
  468 +}
  469 +
  470 +// 11. Expected to throw an error:
  471 +// assert.throws(block, Error_opt, message_opt);
  472 +
  473 +assert.throws = function(block, /*optional*/error, /*optional*/message) {
  474 + _throws(true, block, error, message);
  475 +};
  476 +
  477 +// EXTENSION! This is annoying to write outside this module.
  478 +assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) {
  479 + _throws(false, block, error, message);
  480 +};
  481 +
  482 +assert.ifError = function(err) { if (err) throw err; };
  483 +
  484 +var objectKeys = Object.keys || function (obj) {
  485 + var keys = [];
  486 + for (var key in obj) {
  487 + if (hasOwn.call(obj, key)) keys.push(key);
  488 + }
  489 + return keys;
  490 +};
  1 +{
  2 + "_args": [
  3 + [
  4 + {
  5 + "raw": "assert@>= 0.4.9",
  6 + "scope": null,
  7 + "escapedName": "assert",
  8 + "name": "assert",
  9 + "rawSpec": ">= 0.4.9",
  10 + "spec": ">=0.4.9",
  11 + "type": "range"
  12 + },
  13 + "/Users/fzy/project/koa2_Sequelize_project/node_modules/win32api"
  14 + ]
  15 + ],
  16 + "_from": "assert@>=0.4.9",
  17 + "_id": "assert@1.4.1",
  18 + "_inCache": true,
  19 + "_location": "/assert",
  20 + "_nodeVersion": "5.11.0",
  21 + "_npmOperationalInternal": {
  22 + "host": "packages-16-east.internal.npmjs.com",
  23 + "tmp": "tmp/assert-1.4.1.tgz_1464703323424_0.46298269950784743"
  24 + },
  25 + "_npmUser": {
  26 + "name": "cwmma",
  27 + "email": "calvin.metcalf@gmail.com"
  28 + },
  29 + "_npmVersion": "3.8.6",
  30 + "_phantomChildren": {},
  31 + "_requested": {
  32 + "raw": "assert@>= 0.4.9",
  33 + "scope": null,
  34 + "escapedName": "assert",
  35 + "name": "assert",
  36 + "rawSpec": ">= 0.4.9",
  37 + "spec": ">=0.4.9",
  38 + "type": "range"
  39 + },
  40 + "_requiredBy": [
  41 + "/win32api",
  42 + "/win32ole"
  43 + ],
  44 + "_resolved": "https://registry.npmjs.org/assert/-/assert-1.4.1.tgz",
  45 + "_shasum": "99912d591836b5a6f5b345c0f07eefc08fc65d91",
  46 + "_shrinkwrap": null,
  47 + "_spec": "assert@>= 0.4.9",
  48 + "_where": "/Users/fzy/project/koa2_Sequelize_project/node_modules/win32api",
  49 + "bugs": {
  50 + "url": "https://github.com/defunctzombie/commonjs-assert/issues"
  51 + },
  52 + "dependencies": {
  53 + "util": "0.10.3"
  54 + },
  55 + "description": "commonjs assert - node.js api compatible",
  56 + "devDependencies": {
  57 + "mocha": "~1.21.4",
  58 + "zuul": "~3.10.0",
  59 + "zuul-ngrok": "^4.0.0"
  60 + },
  61 + "directories": {},
  62 + "dist": {
  63 + "shasum": "99912d591836b5a6f5b345c0f07eefc08fc65d91",
  64 + "tarball": "https://registry.npmjs.org/assert/-/assert-1.4.1.tgz"
  65 + },
  66 + "gitHead": "ea25d53a51201cf268681c5ec37f7d51b2d82884",
  67 + "homepage": "https://github.com/defunctzombie/commonjs-assert",
  68 + "keywords": [
  69 + "assert"
  70 + ],
  71 + "license": "MIT",
  72 + "main": "./assert.js",
  73 + "maintainers": [
  74 + {
  75 + "name": "coolaj86",
  76 + "email": "coolaj86@gmail.com"
  77 + },
  78 + {
  79 + "name": "cwmma",
  80 + "email": "calvin.metcalf@gmail.com"
  81 + },
  82 + {
  83 + "name": "defunctzombie",
  84 + "email": "shtylman@gmail.com"
  85 + }
  86 + ],
  87 + "name": "assert",
  88 + "optionalDependencies": {},
  89 + "readme": "# assert\n\n[![Build Status](https://travis-ci.org/defunctzombie/commonjs-assert.svg?branch=master)](https://travis-ci.org/defunctzombie/commonjs-assert)\n\nThis module is used for writing unit tests for your applications, you can access it with require('assert').\n\nThe API is derived from the [commonjs 1.0 unit testing](http://wiki.commonjs.org/wiki/Unit_Testing/1.0) spec and the [node.js assert module](http://nodejs.org/api/assert.html)\n\n## assert.fail(actual, expected, message, operator)\nThrows an exception that displays the values for actual and expected separated by the provided operator.\n\n## assert(value, message), assert.ok(value, [message])\nTests if value is truthy, it is equivalent to assert.equal(true, !!value, message);\n\n## assert.equal(actual, expected, [message])\nTests shallow, coercive equality with the equal comparison operator ( == ).\n\n## assert.notEqual(actual, expected, [message])\nTests shallow, coercive non-equality with the not equal comparison operator ( != ).\n\n## assert.deepEqual(actual, expected, [message])\nTests for deep equality.\n\n## assert.notDeepEqual(actual, expected, [message])\nTests for any deep inequality.\n\n## assert.strictEqual(actual, expected, [message])\nTests strict equality, as determined by the strict equality operator ( === )\n\n## assert.notStrictEqual(actual, expected, [message])\nTests strict non-equality, as determined by the strict not equal operator ( !== )\n\n## assert.throws(block, [error], [message])\nExpects block to throw an error. error can be constructor, regexp or validation function.\n\nValidate instanceof using constructor:\n\n```javascript\nassert.throws(function() { throw new Error(\"Wrong value\"); }, Error);\n```\n\nValidate error message using RegExp:\n\n```javascript\nassert.throws(function() { throw new Error(\"Wrong value\"); }, /value/);\n```\n\nCustom error validation:\n\n```javascript\nassert.throws(function() {\n throw new Error(\"Wrong value\");\n}, function(err) {\n if ( (err instanceof Error) && /value/.test(err) ) {\n return true;\n }\n}, \"unexpected error\");\n```\n\n## assert.doesNotThrow(block, [message])\nExpects block not to throw an error, see assert.throws for details.\n\n## assert.ifError(value)\nTests if value is not a false value, throws if it is a true value. Useful when testing the first argument, error in callbacks.\n",
  90 + "readmeFilename": "README.md",
  91 + "repository": {
  92 + "type": "git",
  93 + "url": "git://github.com/defunctzombie/commonjs-assert.git"
  94 + },
  95 + "scripts": {
  96 + "browser-local": "zuul --no-coverage --local 8000 -- test.js",
  97 + "test": "npm run test-node && npm run test-browser",
  98 + "test-browser": "zuul -- test.js",
  99 + "test-native": "TEST_NATIVE=true mocha --ui qunit test.js",
  100 + "test-node": "mocha --ui qunit test.js"
  101 + },
  102 + "version": "1.4.1"
  103 +}
  1 +// Copyright Joyent, Inc. and other Node contributors.
  2 +//
  3 +// Permission is hereby granted, free of charge, to any person obtaining a
  4 +// copy of this software and associated documentation files (the
  5 +// "Software"), to deal in the Software without restriction, including
  6 +// without limitation the rights to use, copy, modify, merge, publish,
  7 +// distribute, sublicense, and/or sell copies of the Software, and to permit
  8 +// persons to whom the Software is furnished to do so, subject to the
  9 +// following conditions:
  10 +//
  11 +// The above copyright notice and this permission notice shall be included
  12 +// in all copies or substantial portions of the Software.
  13 +//
  14 +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  15 +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  16 +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  17 +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  18 +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  19 +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  20 +// USE OR OTHER DEALINGS IN THE SOFTWARE.
  21 +
  22 +var nodeAssert = require('assert');
  23 +var ourAssert = require('./');
  24 +var keys = Object.keys;
  25 +if (process.env.TEST_NATIVE === true) {
  26 + tests(nodeAssert, 'node assert');
  27 +} else {
  28 + tests(ourAssert, 'our assert');
  29 +}
  30 +
  31 +function makeBlock(f) {
  32 + var args = Array.prototype.slice.call(arguments, 1);
  33 + return function() {
  34 + return f.apply(this, args);
  35 + };
  36 +}
  37 +
  38 +function tests (assert, what) {
  39 + test('assert.ok', function () {
  40 + assert.throws(makeBlock(assert, false), assert.AssertionError, 'ok(false)');
  41 +
  42 + assert.doesNotThrow(makeBlock(assert, true), assert.AssertionError, 'ok(true)');
  43 +
  44 + assert.doesNotThrow(makeBlock(assert, 'test', 'ok(\'test\')'));
  45 +
  46 + assert.throws(makeBlock(assert.ok, false),
  47 + assert.AssertionError, 'ok(false)');
  48 +
  49 + assert.doesNotThrow(makeBlock(assert.ok, true),
  50 + assert.AssertionError, 'ok(true)');
  51 +
  52 + assert.doesNotThrow(makeBlock(assert.ok, 'test'), 'ok(\'test\')');
  53 + });
  54 +
  55 + test('assert.equal', function () {
  56 + assert.throws(makeBlock(assert.equal, true, false), assert.AssertionError, 'equal');
  57 +
  58 + assert.doesNotThrow(makeBlock(assert.equal, null, null), 'equal');
  59 +
  60 + assert.doesNotThrow(makeBlock(assert.equal, undefined, undefined), 'equal');
  61 +
  62 + assert.doesNotThrow(makeBlock(assert.equal, null, undefined), 'equal');
  63 +
  64 + assert.doesNotThrow(makeBlock(assert.equal, true, true), 'equal');
  65 +
  66 + assert.doesNotThrow(makeBlock(assert.equal, 2, '2'), 'equal');
  67 +
  68 + assert.doesNotThrow(makeBlock(assert.notEqual, true, false), 'notEqual');
  69 +
  70 + assert.throws(makeBlock(assert.notEqual, true, true),
  71 + assert.AssertionError, 'notEqual');
  72 + });
  73 +
  74 + test('assert.strictEqual', function () {
  75 + assert.throws(makeBlock(assert.strictEqual, 2, '2'),
  76 + assert.AssertionError, 'strictEqual');
  77 +
  78 + assert.throws(makeBlock(assert.strictEqual, null, undefined),
  79 + assert.AssertionError, 'strictEqual');
  80 +
  81 + assert.doesNotThrow(makeBlock(assert.notStrictEqual, 2, '2'), 'notStrictEqual');
  82 + });
  83 +
  84 + test('assert.deepStrictEqual', function () {
  85 + assert.throws(makeBlock(assert.deepStrictEqual, [2], ['2']),
  86 + assert.AssertionError, 'deepStrictEqual');
  87 +
  88 + assert.throws(makeBlock(assert.deepStrictEqual, [null], [undefined]),
  89 + assert.AssertionError, 'deepStrictEqual');
  90 +
  91 + assert.doesNotThrow(makeBlock(assert.notDeepStrictEqual, [2], ['2']), 'notDeepStrictEqual');
  92 + });
  93 +
  94 + test('assert.deepEqual - 7.2', function () {
  95 + assert.doesNotThrow(makeBlock(assert.deepEqual, new Date(2000, 3, 14),
  96 + new Date(2000, 3, 14)), 'deepEqual date');
  97 +
  98 + assert.throws(makeBlock(assert.deepEqual, new Date(), new Date(2000, 3, 14)),
  99 + assert.AssertionError,
  100 + 'deepEqual date');
  101 + });
  102 +
  103 + test('assert.deepEqual - 7.3', function () {
  104 + assert.doesNotThrow(makeBlock(assert.deepEqual, /a/, /a/));
  105 + assert.doesNotThrow(makeBlock(assert.deepEqual, /a/g, /a/g));
  106 + assert.doesNotThrow(makeBlock(assert.deepEqual, /a/i, /a/i));
  107 + assert.doesNotThrow(makeBlock(assert.deepEqual, /a/m, /a/m));
  108 + assert.doesNotThrow(makeBlock(assert.deepEqual, /a/igm, /a/igm));
  109 + assert.throws(makeBlock(assert.deepEqual, /ab/, /a/));
  110 + assert.throws(makeBlock(assert.deepEqual, /a/g, /a/));
  111 + assert.throws(makeBlock(assert.deepEqual, /a/i, /a/));
  112 + assert.throws(makeBlock(assert.deepEqual, /a/m, /a/));
  113 + assert.throws(makeBlock(assert.deepEqual, /a/igm, /a/im));
  114 +
  115 + var re1 = /a/;
  116 + re1.lastIndex = 3;
  117 + assert.throws(makeBlock(assert.deepEqual, re1, /a/));
  118 + });
  119 +
  120 + test('assert.deepEqual - 7.4', function () {
  121 + assert.doesNotThrow(makeBlock(assert.deepEqual, 4, '4'), 'deepEqual == check');
  122 + assert.doesNotThrow(makeBlock(assert.deepEqual, true, 1), 'deepEqual == check');
  123 + assert.throws(makeBlock(assert.deepEqual, 4, '5'),
  124 + assert.AssertionError,
  125 + 'deepEqual == check');
  126 + });
  127 +
  128 + test('assert.deepEqual - 7.5', function () {
  129 + // having the same number of owned properties && the same set of keys
  130 + assert.doesNotThrow(makeBlock(assert.deepEqual, {a: 4}, {a: 4}));
  131 + assert.doesNotThrow(makeBlock(assert.deepEqual, {a: 4, b: '2'}, {a: 4, b: '2'}));
  132 + assert.doesNotThrow(makeBlock(assert.deepEqual, [4], ['4']));
  133 + assert.throws(makeBlock(assert.deepEqual, {a: 4}, {a: 4, b: true}),
  134 + assert.AssertionError);
  135 + assert.doesNotThrow(makeBlock(assert.deepEqual, ['a'], {0: 'a'}));
  136 + //(although not necessarily the same order),
  137 + assert.doesNotThrow(makeBlock(assert.deepEqual, {a: 4, b: '1'}, {b: '1', a: 4}));
  138 + var a1 = [1, 2, 3];
  139 + var a2 = [1, 2, 3];
  140 + a1.a = 'test';
  141 + a1.b = true;
  142 + a2.b = true;
  143 + a2.a = 'test';
  144 + assert.throws(makeBlock(assert.deepEqual, keys(a1), keys(a2)),
  145 + assert.AssertionError);
  146 + assert.doesNotThrow(makeBlock(assert.deepEqual, a1, a2));
  147 + });
  148 +
  149 + test('assert.deepEqual - ES6 primitives', function () {
  150 + assert.throws(makeBlock(assert.deepEqual, null, {}), assert.AssertionError);
  151 + assert.throws(makeBlock(assert.deepEqual, undefined, {}), assert.AssertionError);
  152 + assert.throws(makeBlock(assert.deepEqual, 'a', ['a']), assert.AssertionError);
  153 + assert.throws(makeBlock(assert.deepEqual, 'a', {0: 'a'}), assert.AssertionError);
  154 + assert.throws(makeBlock(assert.deepEqual, 1, {}), assert.AssertionError);
  155 + assert.throws(makeBlock(assert.deepEqual, true, {}), assert.AssertionError);
  156 + if (typeof Symbol === 'symbol') {
  157 + assert.throws(makeBlock(assert.deepEqual, Symbol(), {}), assert.AssertionError);
  158 + }
  159 + });
  160 +
  161 + test('assert.deepEqual - object wrappers', function () {
  162 + assert.doesNotThrow(makeBlock(assert.deepEqual, new String('a'), ['a']));
  163 + assert.doesNotThrow(makeBlock(assert.deepEqual, new String('a'), {0: 'a'}));
  164 + assert.doesNotThrow(makeBlock(assert.deepEqual, new Number(1), {}));
  165 + assert.doesNotThrow(makeBlock(assert.deepEqual, new Boolean(true), {}));
  166 + });
  167 +
  168 + test('assert.deepEqual - Buffers', function () {
  169 + assert.doesNotThrow(makeBlock(assert.deepEqual, new Buffer([1, 2, 3]), new Buffer([1, 2, 3])));
  170 + if (typeof global.Uint8Array === 'function') {
  171 + assert.throws(makeBlock(assert.deepEqual, new Buffer([1, 2, 3]), new Uint8Array([1, 2, 3])));
  172 + }
  173 + if (typeof global.Uint16Array === 'function') {
  174 + assert.doesNotThrow(makeBlock(assert.deepEqual, new Uint16Array([1, 2, 3]), new Uint16Array([1, 2, 3])));
  175 + }
  176 + });
  177 +
  178 + function thrower(errorConstructor) {
  179 + throw new errorConstructor('test');
  180 + }
  181 +
  182 + test('assert - Testing the throwing', function () {
  183 + var aethrow = makeBlock(thrower, assert.AssertionError);
  184 + aethrow = makeBlock(thrower, assert.AssertionError);
  185 +
  186 + // the basic calls work
  187 + assert.throws(makeBlock(thrower, assert.AssertionError),
  188 + assert.AssertionError, 'message');
  189 + assert.throws(makeBlock(thrower, assert.AssertionError), assert.AssertionError);
  190 + assert.throws(makeBlock(thrower, assert.AssertionError));
  191 +
  192 + // if not passing an error, catch all.
  193 + assert.throws(makeBlock(thrower, TypeError));
  194 +
  195 + // when passing a type, only catch errors of the appropriate type
  196 + var threw = false;
  197 + try {
  198 + assert.throws(makeBlock(thrower, TypeError), assert.AssertionError);
  199 + } catch (e) {
  200 + threw = true;
  201 + assert.ok(e instanceof TypeError, 'type');
  202 + }
  203 + assert.equal(true, threw,
  204 + 'a.throws with an explicit error is eating extra errors',
  205 + assert.AssertionError);
  206 + threw = false;
  207 +
  208 + // doesNotThrow should pass through all errors
  209 + try {
  210 + assert.doesNotThrow(makeBlock(thrower, TypeError), assert.AssertionError);
  211 + } catch (e) {
  212 + threw = true;
  213 + assert.ok(e instanceof TypeError);
  214 + }
  215 + assert.equal(true, threw,
  216 + 'a.doesNotThrow with an explicit error is eating extra errors');
  217 +
  218 + // key difference is that throwing our correct error makes an assertion error
  219 + try {
  220 + assert.doesNotThrow(makeBlock(thrower, TypeError), TypeError);
  221 + } catch (e) {
  222 + threw = true;
  223 + assert.ok(e instanceof assert.AssertionError);
  224 + }
  225 + assert.equal(true, threw,
  226 + 'a.doesNotThrow is not catching type matching errors');
  227 + });
  228 +
  229 + test('assert.ifError', function () {
  230 + assert.throws(function() {assert.ifError(new Error('test error'))});
  231 + assert.doesNotThrow(function() {assert.ifError(null)});
  232 + assert.doesNotThrow(function() {assert.ifError()});
  233 + });
  234 +
  235 + test('assert - make sure that validating using constructor really works', function () {
  236 + var threw = false;
  237 + try {
  238 + assert.throws(
  239 + function() {
  240 + throw ({});
  241 + },
  242 + Array
  243 + );
  244 + } catch (e) {
  245 + threw = true;
  246 + }
  247 + assert.ok(threw, 'wrong constructor validation');
  248 + });
  249 +
  250 + test('assert - use a RegExp to validate error message', function () {
  251 + assert.throws(makeBlock(thrower, TypeError), /test/);
  252 + });
  253 +
  254 + test('assert - se a fn to validate error object', function () {
  255 + assert.throws(makeBlock(thrower, TypeError), function(err) {
  256 + if ((err instanceof TypeError) && /test/.test(err)) {
  257 + return true;
  258 + }
  259 + });
  260 + });
  261 +
  262 + test('assert - Make sure deepEqual doesn\'t loop forever on circular refs', function () {
  263 + var b = {};
  264 + b.b = b;
  265 +
  266 + var c = {};
  267 + c.b = c;
  268 +
  269 + var gotError = false;
  270 + var equal = true;
  271 + try {
  272 + equal = assert.deepEqual(b, c);
  273 + } catch (e) {
  274 + gotError = true;
  275 + }
  276 + assert.ok(gotError || !equal, gotError ? 'got error': 'are equal');
  277 + });
  278 +
  279 + test('assert - Ensure reflexivity of deepEqual with `arguments` objects', function() {
  280 + var args = (function() { return arguments; })();
  281 + assert.throws(makeBlock(assert.deepEqual, [], args), assert.AssertionError);
  282 + assert.throws(makeBlock(assert.deepEqual, args, []), assert.AssertionError);
  283 + });
  284 +
  285 + test('assert - test assertion message', function () {
  286 + function testAssertionMessage(actual, expected) {
  287 + try {
  288 + assert.equal(actual, '');
  289 + } catch (e) {
  290 + assert.equal(e.toString(),
  291 + ['AssertionError:', expected, '==', '\'\''].join(' '));
  292 + }
  293 + }
  294 + testAssertionMessage(undefined, 'undefined');
  295 + testAssertionMessage(null, 'null');
  296 + testAssertionMessage(true, 'true');
  297 + testAssertionMessage(false, 'false');
  298 + testAssertionMessage(0, '0');
  299 + testAssertionMessage(100, '100');
  300 + testAssertionMessage(NaN, 'NaN');
  301 + testAssertionMessage(Infinity, 'Infinity');
  302 + testAssertionMessage(-Infinity, '-Infinity');
  303 + testAssertionMessage('', '""');
  304 + testAssertionMessage('foo', '\'foo\'');
  305 + testAssertionMessage([], '[]');
  306 + testAssertionMessage([1, 2, 3], '[ 1, 2, 3 ]');
  307 + testAssertionMessage(new Buffer([1, 2, 3]), '<Buffer 01 02 03>');
  308 + if (typeof global.Uint8Array === 'function' && Object.getOwnPropertyNames( new Uint8Array([])).length === 0) {
  309 + // todo fix util.inspect
  310 + testAssertionMessage(new Uint8Array([1, 2, 3]), '{ \'0\': 1, \'1\': 2, \'2\': 3 }');
  311 + }
  312 + testAssertionMessage(/a/, '/a/');
  313 + testAssertionMessage(function f() {}, '[Function: f]');
  314 + testAssertionMessage({}, '{}');
  315 + testAssertionMessage({a: undefined, b: null}, '{ a: undefined, b: null }');
  316 + testAssertionMessage({a: NaN, b: Infinity, c: -Infinity},
  317 + '{ a: NaN, b: Infinity, c: -Infinity }');
  318 + });
  319 +
  320 + test('assert - regressions from node.js testcase', function () {
  321 + var threw = false;
  322 +
  323 + try {
  324 + assert.throws(function () {
  325 + assert.ifError(null);
  326 + });
  327 + } catch (e) {
  328 + threw = true;
  329 + assert.equal(e.message, 'Missing expected exception..');
  330 + }
  331 + assert.ok(threw);
  332 +
  333 + try {
  334 + assert.equal(1, 2);
  335 + } catch (e) {
  336 + assert.equal(e.toString().split('\n')[0], 'AssertionError: 1 == 2');
  337 + }
  338 +
  339 + try {
  340 + assert.equal(1, 2, 'oh no');
  341 + } catch (e) {
  342 + assert.equal(e.toString().split('\n')[0], 'AssertionError: oh no');
  343 + }
  344 + });
  345 +}
  1 +node-bindings
  2 +=============
  3 +### Helper module for loading your native module's .node file
  4 +
  5 +This is a helper module for authors of Node.js native addon modules.
  6 +It is basically the "swiss army knife" of `require()`ing your native module's
  7 +`.node` file.
  8 +
  9 +Throughout the course of Node's native addon history, addons have ended up being
  10 +compiled in a variety of different places, depending on which build tool and which
  11 +version of node was used. To make matters worse, now the _gyp_ build tool can
  12 +produce either a _Release_ or _Debug_ build, each being built into different
  13 +locations.
  14 +
  15 +This module checks _all_ the possible locations that a native addon would be built
  16 +at, and returns the first one that loads successfully.
  17 +
  18 +
  19 +Installation
  20 +------------
  21 +
  22 +Install with `npm`:
  23 +
  24 +``` bash
  25 +$ npm install bindings
  26 +```
  27 +
  28 +Or add it to the `"dependencies"` section of your _package.json_ file.
  29 +
  30 +
  31 +Example
  32 +-------
  33 +
  34 +`require()`ing the proper bindings file for the current node version, platform
  35 +and architecture is as simple as:
  36 +
  37 +``` js
  38 +var bindings = require('bindings')('binding.node')
  39 +
  40 +// Use your bindings defined in your C files
  41 +bindings.your_c_function()
  42 +```
  43 +
  44 +
  45 +Nice Error Output
  46 +-----------------
  47 +
  48 +When the `.node` file could not be loaded, `node-bindings` throws an Error with
  49 +a nice error message telling you exactly what was tried. You can also check the
  50 +`err.tries` Array property.
  51 +
  52 +```
  53 +Error: Could not load the bindings file. Tried:
  54 + → /Users/nrajlich/ref/build/binding.node
  55 + → /Users/nrajlich/ref/build/Debug/binding.node
  56 + → /Users/nrajlich/ref/build/Release/binding.node
  57 + → /Users/nrajlich/ref/out/Debug/binding.node
  58 + → /Users/nrajlich/ref/Debug/binding.node
  59 + → /Users/nrajlich/ref/out/Release/binding.node
  60 + → /Users/nrajlich/ref/Release/binding.node
  61 + → /Users/nrajlich/ref/build/default/binding.node
  62 + → /Users/nrajlich/ref/compiled/0.8.2/darwin/x64/binding.node
  63 + at bindings (/Users/nrajlich/ref/node_modules/bindings/bindings.js:84:13)
  64 + at Object.<anonymous> (/Users/nrajlich/ref/lib/ref.js:5:47)
  65 + at Module._compile (module.js:449:26)
  66 + at Object.Module._extensions..js (module.js:467:10)
  67 + at Module.load (module.js:356:32)
  68 + at Function.Module._load (module.js:312:12)
  69 + ...
  70 +```
  71 +
  72 +The searching for the `.node` file will originate from the first directory in which has a `package.json` file is found.
  73 +
  74 +License
  75 +-------
  76 +
  77 +(The MIT License)
  78 +
  79 +Copyright (c) 2012 Nathan Rajlich &lt;nathan@tootallnate.net&gt;
  80 +
  81 +Permission is hereby granted, free of charge, to any person obtaining
  82 +a copy of this software and associated documentation files (the
  83 +'Software'), to deal in the Software without restriction, including
  84 +without limitation the rights to use, copy, modify, merge, publish,
  85 +distribute, sublicense, and/or sell copies of the Software, and to
  86 +permit persons to whom the Software is furnished to do so, subject to
  87 +the following conditions:
  88 +
  89 +The above copyright notice and this permission notice shall be
  90 +included in all copies or substantial portions of the Software.
  91 +
  92 +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
  93 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  94 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  95 +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  96 +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  97 +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  98 +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  1 +
  2 +/**
  3 + * Module dependencies.
  4 + */
  5 +
  6 +var fs = require('fs')
  7 + , path = require('path')
  8 + , join = path.join
  9 + , dirname = path.dirname
  10 + , exists = ((fs.accessSync && function (path) { try { fs.accessSync(path); } catch (e) { return false; } return true; })
  11 + || fs.existsSync || path.existsSync)
  12 + , defaults = {
  13 + arrow: process.env.NODE_BINDINGS_ARROW || ' → '
  14 + , compiled: process.env.NODE_BINDINGS_COMPILED_DIR || 'compiled'
  15 + , platform: process.platform
  16 + , arch: process.arch
  17 + , version: process.versions.node
  18 + , bindings: 'bindings.node'
  19 + , try: [
  20 + // node-gyp's linked version in the "build" dir
  21 + [ 'module_root', 'build', 'bindings' ]
  22 + // node-waf and gyp_addon (a.k.a node-gyp)
  23 + , [ 'module_root', 'build', 'Debug', 'bindings' ]
  24 + , [ 'module_root', 'build', 'Release', 'bindings' ]
  25 + // Debug files, for development (legacy behavior, remove for node v0.9)
  26 + , [ 'module_root', 'out', 'Debug', 'bindings' ]
  27 + , [ 'module_root', 'Debug', 'bindings' ]
  28 + // Release files, but manually compiled (legacy behavior, remove for node v0.9)
  29 + , [ 'module_root', 'out', 'Release', 'bindings' ]
  30 + , [ 'module_root', 'Release', 'bindings' ]
  31 + // Legacy from node-waf, node <= 0.4.x
  32 + , [ 'module_root', 'build', 'default', 'bindings' ]
  33 + // Production "Release" buildtype binary (meh...)
  34 + , [ 'module_root', 'compiled', 'version', 'platform', 'arch', 'bindings' ]
  35 + ]
  36 + }
  37 +
  38 +/**
  39 + * The main `bindings()` function loads the compiled bindings for a given module.
  40 + * It uses V8's Error API to determine the parent filename that this function is
  41 + * being invoked from, which is then used to find the root directory.
  42 + */
  43 +
  44 +function bindings (opts) {
  45 +
  46 + // Argument surgery
  47 + if (typeof opts == 'string') {
  48 + opts = { bindings: opts }
  49 + } else if (!opts) {
  50 + opts = {}
  51 + }
  52 +
  53 + // maps `defaults` onto `opts` object
  54 + Object.keys(defaults).map(function(i) {
  55 + if (!(i in opts)) opts[i] = defaults[i];
  56 + });
  57 +
  58 + // Get the module root
  59 + if (!opts.module_root) {
  60 + opts.module_root = exports.getRoot(exports.getFileName())
  61 + }
  62 +
  63 + // Ensure the given bindings name ends with .node
  64 + if (path.extname(opts.bindings) != '.node') {
  65 + opts.bindings += '.node'
  66 + }
  67 +
  68 + var tries = []
  69 + , i = 0
  70 + , l = opts.try.length
  71 + , n
  72 + , b
  73 + , err
  74 +
  75 + for (; i<l; i++) {
  76 + n = join.apply(null, opts.try[i].map(function (p) {
  77 + return opts[p] || p
  78 + }))
  79 + tries.push(n)
  80 + try {
  81 + b = opts.path ? require.resolve(n) : require(n)
  82 + if (!opts.path) {
  83 + b.path = n
  84 + }
  85 + return b
  86 + } catch (e) {
  87 + if (!/not find/i.test(e.message)) {
  88 + throw e
  89 + }
  90 + }
  91 + }
  92 +
  93 + err = new Error('Could not locate the bindings file. Tried:\n'
  94 + + tries.map(function (a) { return opts.arrow + a }).join('\n'))
  95 + err.tries = tries
  96 + throw err
  97 +}
  98 +module.exports = exports = bindings
  99 +
  100 +
  101 +/**
  102 + * Gets the filename of the JavaScript file that invokes this function.
  103 + * Used to help find the root directory of a module.
  104 + * Optionally accepts an filename argument to skip when searching for the invoking filename
  105 + */
  106 +
  107 +exports.getFileName = function getFileName (calling_file) {
  108 + var origPST = Error.prepareStackTrace
  109 + , origSTL = Error.stackTraceLimit
  110 + , dummy = {}
  111 + , fileName
  112 +
  113 + Error.stackTraceLimit = 10
  114 +
  115 + Error.prepareStackTrace = function (e, st) {
  116 + for (var i=0, l=st.length; i<l; i++) {
  117 + fileName = st[i].getFileName()
  118 + if (fileName !== __filename) {
  119 + if (calling_file) {
  120 + if (fileName !== calling_file) {
  121 + return
  122 + }
  123 + } else {
  124 + return
  125 + }
  126 + }
  127 + }
  128 + }
  129 +
  130 + // run the 'prepareStackTrace' function above
  131 + Error.captureStackTrace(dummy)
  132 + dummy.stack
  133 +
  134 + // cleanup
  135 + Error.prepareStackTrace = origPST
  136 + Error.stackTraceLimit = origSTL
  137 +
  138 + return fileName
  139 +}
  140 +
  141 +/**
  142 + * Gets the root directory of a module, given an arbitrary filename
  143 + * somewhere in the module tree. The "root directory" is the directory
  144 + * containing the `package.json` file.
  145 + *
  146 + * In: /home/nate/node-native-module/lib/index.js
  147 + * Out: /home/nate/node-native-module
  148 + */
  149 +
  150 +exports.getRoot = function getRoot (file) {
  151 + var dir = dirname(file)
  152 + , prev
  153 + while (true) {
  154 + if (dir === '.') {
  155 + // Avoids an infinite loop in rare cases, like the REPL
  156 + dir = process.cwd()
  157 + }
  158 + if (exists(join(dir, 'package.json')) || exists(join(dir, 'node_modules'))) {
  159 + // Found the 'package.json' file or 'node_modules' dir; we're done
  160 + return dir
  161 + }
  162 + if (prev === dir) {
  163 + // Got to the top
  164 + throw new Error('Could not find module root given file: "' + file
  165 + + '". Do you have a `package.json` file? ')
  166 + }
  167 + // Try the parent dir next
  168 + prev = dir
  169 + dir = join(dir, '..')
  170 + }
  171 +}
  1 +{
  2 + "_args": [
  3 + [
  4 + {
  5 + "raw": "bindings@1",
  6 + "scope": null,
  7 + "escapedName": "bindings",
  8 + "name": "bindings",
  9 + "rawSpec": "1",
  10 + "spec": ">=1.0.0 <2.0.0",
  11 + "type": "range"
  12 + },
  13 + "/Users/fzy/project/koa2_Sequelize_project/node_modules/node-proxy"
  14 + ]
  15 + ],
  16 + "_from": "bindings@>=1.0.0 <2.0.0",
  17 + "_id": "bindings@1.3.0",
  18 + "_inCache": true,
  19 + "_location": "/bindings",
  20 + "_nodeVersion": "8.1.3",
  21 + "_npmOperationalInternal": {
  22 + "host": "s3://npm-registry-packages",
  23 + "tmp": "tmp/bindings-1.3.0.tgz_1500923768710_0.3334669852629304"
  24 + },
  25 + "_npmUser": {
  26 + "name": "tootallnate",
  27 + "email": "nathan@tootallnate.net"
  28 + },
  29 + "_npmVersion": "5.0.3",
  30 + "_phantomChildren": {},
  31 + "_requested": {
  32 + "raw": "bindings@1",
  33 + "scope": null,
  34 + "escapedName": "bindings",
  35 + "name": "bindings",
  36 + "rawSpec": "1",
  37 + "spec": ">=1.0.0 <2.0.0",
  38 + "type": "range"
  39 + },
  40 + "_requiredBy": [
  41 + "/node-proxy",
  42 + "/ref"
  43 + ],
  44 + "_resolved": "https://registry.npmjs.org/bindings/-/bindings-1.3.0.tgz",
  45 + "_shasum": "b346f6ecf6a95f5a815c5839fc7cdb22502f1ed7",
  46 + "_shrinkwrap": null,
  47 + "_spec": "bindings@1",
  48 + "_where": "/Users/fzy/project/koa2_Sequelize_project/node_modules/node-proxy",
  49 + "author": {
  50 + "name": "Nathan Rajlich",
  51 + "email": "nathan@tootallnate.net",
  52 + "url": "http://tootallnate.net"
  53 + },
  54 + "bugs": {
  55 + "url": "https://github.com/TooTallNate/node-bindings/issues"
  56 + },
  57 + "dependencies": {},
  58 + "description": "Helper module for loading your native module's .node file",
  59 + "devDependencies": {},
  60 + "directories": {},
  61 + "dist": {
  62 + "integrity": "sha512-DpLh5EzMR2kzvX1KIlVC0VkC3iZtHKTgdtZ0a3pglBZdaQFjt5S9g9xd1lE+YvXyfd6mtCeRnrUfOLYiTMlNSw==",
  63 + "shasum": "b346f6ecf6a95f5a815c5839fc7cdb22502f1ed7",
  64 + "tarball": "https://registry.npmjs.org/bindings/-/bindings-1.3.0.tgz"
  65 + },
  66 + "gitHead": "7fd065ee85386ad3d074d2506e03abe8f9b1588b",
  67 + "homepage": "https://github.com/TooTallNate/node-bindings",
  68 + "keywords": [
  69 + "native",
  70 + "addon",
  71 + "bindings",
  72 + "gyp",
  73 + "waf",
  74 + "c",
  75 + "c++"
  76 + ],
  77 + "license": "MIT",
  78 + "main": "./bindings.js",
  79 + "maintainers": [
  80 + {
  81 + "name": "tootallnate",
  82 + "email": "nathan@tootallnate.net"
  83 + }
  84 + ],
  85 + "name": "bindings",
  86 + "optionalDependencies": {},
  87 + "readme": "node-bindings\n=============\n### Helper module for loading your native module's .node file\n\nThis is a helper module for authors of Node.js native addon modules.\nIt is basically the \"swiss army knife\" of `require()`ing your native module's\n`.node` file.\n\nThroughout the course of Node's native addon history, addons have ended up being\ncompiled in a variety of different places, depending on which build tool and which\nversion of node was used. To make matters worse, now the _gyp_ build tool can\nproduce either a _Release_ or _Debug_ build, each being built into different\nlocations.\n\nThis module checks _all_ the possible locations that a native addon would be built\nat, and returns the first one that loads successfully.\n\n\nInstallation\n------------\n\nInstall with `npm`:\n\n``` bash\n$ npm install bindings\n```\n\nOr add it to the `\"dependencies\"` section of your _package.json_ file.\n\n\nExample\n-------\n\n`require()`ing the proper bindings file for the current node version, platform\nand architecture is as simple as:\n\n``` js\nvar bindings = require('bindings')('binding.node')\n\n// Use your bindings defined in your C files\nbindings.your_c_function()\n```\n\n\nNice Error Output\n-----------------\n\nWhen the `.node` file could not be loaded, `node-bindings` throws an Error with\na nice error message telling you exactly what was tried. You can also check the\n`err.tries` Array property.\n\n```\nError: Could not load the bindings file. Tried:\n → /Users/nrajlich/ref/build/binding.node\n → /Users/nrajlich/ref/build/Debug/binding.node\n → /Users/nrajlich/ref/build/Release/binding.node\n → /Users/nrajlich/ref/out/Debug/binding.node\n → /Users/nrajlich/ref/Debug/binding.node\n → /Users/nrajlich/ref/out/Release/binding.node\n → /Users/nrajlich/ref/Release/binding.node\n → /Users/nrajlich/ref/build/default/binding.node\n → /Users/nrajlich/ref/compiled/0.8.2/darwin/x64/binding.node\n at bindings (/Users/nrajlich/ref/node_modules/bindings/bindings.js:84:13)\n at Object.<anonymous> (/Users/nrajlich/ref/lib/ref.js:5:47)\n at Module._compile (module.js:449:26)\n at Object.Module._extensions..js (module.js:467:10)\n at Module.load (module.js:356:32)\n at Function.Module._load (module.js:312:12)\n ...\n```\n\nThe searching for the `.node` file will originate from the first directory in which has a `package.json` file is found. \n\nLicense\n-------\n\n(The MIT License)\n\nCopyright (c) 2012 Nathan Rajlich &lt;nathan@tootallnate.net&gt;\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n",
  88 + "readmeFilename": "README.md",
  89 + "repository": {
  90 + "type": "git",
  91 + "url": "git://github.com/TooTallNate/node-bindings.git"
  92 + },
  93 + "version": "1.3.0"
  94 +}
  1 +Copyright (c) Isaac Z. Schlueter
  2 +All rights reserved.
  3 +
  4 +The BSD License
  5 +
  6 +Redistribution and use in source and binary forms, with or without
  7 +modification, are permitted provided that the following conditions
  8 +are met:
  9 +1. Redistributions of source code must retain the above copyright
  10 + notice, this list of conditions and the following disclaimer.
  11 +2. Redistributions in binary form must reproduce the above copyright
  12 + notice, this list of conditions and the following disclaimer in the
  13 + documentation and/or other materials provided with the distribution.
  14 +
  15 +THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
  16 +``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
  17 +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  18 +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
  19 +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  20 +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  21 +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  22 +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  23 +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  24 +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  25 +POSSIBILITY OF SUCH DAMAGE.
  1 +The ISC License
  2 +
  3 +Copyright (c) Isaac Z. Schlueter and Contributors
  4 +
  5 +Permission to use, copy, modify, and/or distribute this software for any
  6 +purpose with or without fee is hereby granted, provided that the above
  7 +copyright notice and this permission notice appear in all copies.
  8 +
  9 +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10 +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11 +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12 +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13 +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14 +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
  15 +IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  1 +# block-stream
  2 +
  3 +A stream of blocks.
  4 +
  5 +Write data into it, and it'll output data in buffer blocks the size you
  6 +specify, padding with zeroes if necessary.
  7 +
  8 +```javascript
  9 +var block = new BlockStream(512)
  10 +fs.createReadStream("some-file").pipe(block)
  11 +block.pipe(fs.createWriteStream("block-file"))
  12 +```
  13 +
  14 +When `.end()` or `.flush()` is called, it'll pad the block with zeroes.
  1 +// write data to it, and it'll emit data in 512 byte blocks.
  2 +// if you .end() or .flush(), it'll emit whatever it's got,
  3 +// padded with nulls to 512 bytes.
  4 +
  5 +module.exports = BlockStream
  6 +
  7 +var Stream = require("stream").Stream
  8 + , inherits = require("inherits")
  9 + , assert = require("assert").ok
  10 + , debug = process.env.DEBUG ? console.error : function () {}
  11 +
  12 +function BlockStream (size, opt) {
  13 + this.writable = this.readable = true
  14 + this._opt = opt || {}
  15 + this._chunkSize = size || 512
  16 + this._offset = 0
  17 + this._buffer = []
  18 + this._bufferLength = 0
  19 + if (this._opt.nopad) this._zeroes = false
  20 + else {
  21 + this._zeroes = new Buffer(this._chunkSize)
  22 + for (var i = 0; i < this._chunkSize; i ++) {
  23 + this._zeroes[i] = 0
  24 + }
  25 + }
  26 +}
  27 +
  28 +inherits(BlockStream, Stream)
  29 +
  30 +BlockStream.prototype.write = function (c) {
  31 + // debug(" BS write", c)
  32 + if (this._ended) throw new Error("BlockStream: write after end")
  33 + if (c && !Buffer.isBuffer(c)) c = new Buffer(c + "")
  34 + if (c.length) {
  35 + this._buffer.push(c)
  36 + this._bufferLength += c.length
  37 + }
  38 + // debug("pushed onto buffer", this._bufferLength)
  39 + if (this._bufferLength >= this._chunkSize) {
  40 + if (this._paused) {
  41 + // debug(" BS paused, return false, need drain")
  42 + this._needDrain = true
  43 + return false
  44 + }
  45 + this._emitChunk()
  46 + }
  47 + return true
  48 +}
  49 +
  50 +BlockStream.prototype.pause = function () {
  51 + // debug(" BS pausing")
  52 + this._paused = true
  53 +}
  54 +
  55 +BlockStream.prototype.resume = function () {
  56 + // debug(" BS resume")
  57 + this._paused = false
  58 + return this._emitChunk()
  59 +}
  60 +
  61 +BlockStream.prototype.end = function (chunk) {
  62 + // debug("end", chunk)
  63 + if (typeof chunk === "function") cb = chunk, chunk = null
  64 + if (chunk) this.write(chunk)
  65 + this._ended = true
  66 + this.flush()
  67 +}
  68 +
  69 +BlockStream.prototype.flush = function () {
  70 + this._emitChunk(true)
  71 +}
  72 +
  73 +BlockStream.prototype._emitChunk = function (flush) {
  74 + // debug("emitChunk flush=%j emitting=%j paused=%j", flush, this._emitting, this._paused)
  75 +
  76 + // emit a <chunkSize> chunk
  77 + if (flush && this._zeroes) {
  78 + // debug(" BS push zeroes", this._bufferLength)
  79 + // push a chunk of zeroes
  80 + var padBytes = (this._bufferLength % this._chunkSize)
  81 + if (padBytes !== 0) padBytes = this._chunkSize - padBytes
  82 + if (padBytes > 0) {
  83 + // debug("padBytes", padBytes, this._zeroes.slice(0, padBytes))
  84 + this._buffer.push(this._zeroes.slice(0, padBytes))
  85 + this._bufferLength += padBytes
  86 + // debug(this._buffer[this._buffer.length - 1].length, this._bufferLength)
  87 + }
  88 + }
  89 +
  90 + if (this._emitting || this._paused) return
  91 + this._emitting = true
  92 +
  93 + // debug(" BS entering loops")
  94 + var bufferIndex = 0
  95 + while (this._bufferLength >= this._chunkSize &&
  96 + (flush || !this._paused)) {
  97 + // debug(" BS data emission loop", this._bufferLength)
  98 +
  99 + var out
  100 + , outOffset = 0
  101 + , outHas = this._chunkSize
  102 +
  103 + while (outHas > 0 && (flush || !this._paused) ) {
  104 + // debug(" BS data inner emit loop", this._bufferLength)
  105 + var cur = this._buffer[bufferIndex]
  106 + , curHas = cur.length - this._offset
  107 + // debug("cur=", cur)
  108 + // debug("curHas=%j", curHas)
  109 + // If it's not big enough to fill the whole thing, then we'll need
  110 + // to copy multiple buffers into one. However, if it is big enough,
  111 + // then just slice out the part we want, to save unnecessary copying.
  112 + // Also, need to copy if we've already done some copying, since buffers
  113 + // can't be joined like cons strings.
  114 + if (out || curHas < outHas) {
  115 + out = out || new Buffer(this._chunkSize)
  116 + cur.copy(out, outOffset,
  117 + this._offset, this._offset + Math.min(curHas, outHas))
  118 + } else if (cur.length === outHas && this._offset === 0) {
  119 + // shortcut -- cur is exactly long enough, and no offset.
  120 + out = cur
  121 + } else {
  122 + // slice out the piece of cur that we need.
  123 + out = cur.slice(this._offset, this._offset + outHas)
  124 + }
  125 +
  126 + if (curHas > outHas) {
  127 + // means that the current buffer couldn't be completely output
  128 + // update this._offset to reflect how much WAS written
  129 + this._offset += outHas
  130 + outHas = 0
  131 + } else {
  132 + // output the entire current chunk.
  133 + // toss it away
  134 + outHas -= curHas
  135 + outOffset += curHas
  136 + bufferIndex ++
  137 + this._offset = 0
  138 + }
  139 + }
  140 +
  141 + this._bufferLength -= this._chunkSize
  142 + assert(out.length === this._chunkSize)
  143 + // debug("emitting data", out)
  144 + // debug(" BS emitting, paused=%j", this._paused, this._bufferLength)
  145 + this.emit("data", out)
  146 + out = null
  147 + }
  148 + // debug(" BS out of loops", this._bufferLength)
  149 +
  150 + // whatever is left, it's not enough to fill up a block, or we're paused
  151 + this._buffer = this._buffer.slice(bufferIndex)
  152 + if (this._paused) {
  153 + // debug(" BS paused, leaving", this._bufferLength)
  154 + this._needsDrain = true
  155 + this._emitting = false
  156 + return
  157 + }
  158 +
  159 + // if flushing, and not using null-padding, then need to emit the last
  160 + // chunk(s) sitting in the queue. We know that it's not enough to
  161 + // fill up a whole block, because otherwise it would have been emitted
  162 + // above, but there may be some offset.
  163 + var l = this._buffer.length
  164 + if (flush && !this._zeroes && l) {
  165 + if (l === 1) {
  166 + if (this._offset) {
  167 + this.emit("data", this._buffer[0].slice(this._offset))
  168 + } else {
  169 + this.emit("data", this._buffer[0])
  170 + }
  171 + } else {
  172 + var outHas = this._bufferLength
  173 + , out = new Buffer(outHas)
  174 + , outOffset = 0
  175 + for (var i = 0; i < l; i ++) {
  176 + var cur = this._buffer[i]
  177 + , curHas = cur.length - this._offset
  178 + cur.copy(out, outOffset, this._offset)
  179 + this._offset = 0
  180 + outOffset += curHas
  181 + this._bufferLength -= curHas
  182 + }
  183 + this.emit("data", out)
  184 + }
  185 + // truncate
  186 + this._buffer.length = 0
  187 + this._bufferLength = 0
  188 + this._offset = 0
  189 + }
  190 +
  191 + // now either drained or ended
  192 + // debug("either draining, or ended", this._bufferLength, this._ended)
  193 + // means that we've flushed out all that we can so far.
  194 + if (this._needDrain) {
  195 + // debug("emitting drain", this._bufferLength)
  196 + this._needDrain = false
  197 + this.emit("drain")
  198 + }
  199 +
  200 + if ((this._bufferLength === 0) && this._ended && !this._endEmitted) {
  201 + // debug("emitting end", this._bufferLength)
  202 + this._endEmitted = true
  203 + this.emit("end")
  204 + }
  205 +
  206 + this._emitting = false
  207 +
  208 + // debug(" BS no longer emitting", flush, this._paused, this._emitting, this._bufferLength, this._chunkSize)
  209 +}
  1 +{
  2 + "_args": [
  3 + [
  4 + {
  5 + "raw": "block-stream@*",
  6 + "scope": null,
  7 + "escapedName": "block-stream",
  8 + "name": "block-stream",
  9 + "rawSpec": "*",
  10 + "spec": "*",
  11 + "type": "range"
  12 + },
  13 + "/Users/fzy/project/koa2_Sequelize_project/node_modules/tar"
  14 + ]
  15 + ],
  16 + "_from": "block-stream@*",
  17 + "_id": "block-stream@0.0.9",
  18 + "_inCache": true,
  19 + "_location": "/block-stream",
  20 + "_nodeVersion": "5.6.0",
  21 + "_npmOperationalInternal": {
  22 + "host": "packages-16-east.internal.npmjs.com",
  23 + "tmp": "tmp/block-stream-0.0.9.tgz_1462149852620_0.6890447810292244"
  24 + },
  25 + "_npmUser": {
  26 + "name": "isaacs",
  27 + "email": "i@izs.me"
  28 + },
  29 + "_npmVersion": "3.8.5",
  30 + "_phantomChildren": {},
  31 + "_requested": {
  32 + "raw": "block-stream@*",
  33 + "scope": null,
  34 + "escapedName": "block-stream",
  35 + "name": "block-stream",
  36 + "rawSpec": "*",
  37 + "spec": "*",
  38 + "type": "range"
  39 + },
  40 + "_requiredBy": [
  41 + "/tar"
  42 + ],
  43 + "_resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz",
  44 + "_shasum": "13ebfe778a03205cfe03751481ebb4b3300c126a",
  45 + "_shrinkwrap": null,
  46 + "_spec": "block-stream@*",
  47 + "_where": "/Users/fzy/project/koa2_Sequelize_project/node_modules/tar",
  48 + "author": {
  49 + "name": "Isaac Z. Schlueter",
  50 + "email": "i@izs.me",
  51 + "url": "http://blog.izs.me/"
  52 + },
  53 + "bugs": {
  54 + "url": "https://github.com/isaacs/block-stream/issues"
  55 + },
  56 + "dependencies": {
  57 + "inherits": "~2.0.0"
  58 + },
  59 + "description": "a stream of blocks",
  60 + "devDependencies": {
  61 + "tap": "^5.7.1"
  62 + },
  63 + "directories": {},
  64 + "dist": {
  65 + "shasum": "13ebfe778a03205cfe03751481ebb4b3300c126a",
  66 + "tarball": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz"
  67 + },
  68 + "engines": {
  69 + "node": "0.4 || >=0.5.8"
  70 + },
  71 + "files": [
  72 + "block-stream.js"
  73 + ],
  74 + "gitHead": "321cf242ef6d130bb2e59c0565a61ded5dd2673f",
  75 + "homepage": "https://github.com/isaacs/block-stream#readme",
  76 + "license": "ISC",
  77 + "main": "block-stream.js",
  78 + "maintainers": [
  79 + {
  80 + "name": "isaacs",
  81 + "email": "i@izs.me"
  82 + }
  83 + ],
  84 + "name": "block-stream",
  85 + "optionalDependencies": {},
  86 + "readme": "# block-stream\n\nA stream of blocks.\n\nWrite data into it, and it'll output data in buffer blocks the size you\nspecify, padding with zeroes if necessary.\n\n```javascript\nvar block = new BlockStream(512)\nfs.createReadStream(\"some-file\").pipe(block)\nblock.pipe(fs.createWriteStream(\"block-file\"))\n```\n\nWhen `.end()` or `.flush()` is called, it'll pad the block with zeroes.\n",
  87 + "readmeFilename": "README.md",
  88 + "repository": {
  89 + "type": "git",
  90 + "url": "git://github.com/isaacs/block-stream.git"
  91 + },
  92 + "scripts": {
  93 + "test": "tap test/*.js --cov"
  94 + },
  95 + "version": "0.0.9"
  96 +}
  1 +/* eslint-disable babel/new-cap, xo/throw-new-error */
  2 +'use strict';
  3 +module.exports = function (str, pos) {
  4 + if (str === null || str === undefined) {
  5 + throw TypeError();
  6 + }
  7 +
  8 + str = String(str);
  9 +
  10 + var size = str.length;
  11 + var i = pos ? Number(pos) : 0;
  12 +
  13 + if (Number.isNaN(i)) {
  14 + i = 0;
  15 + }
  16 +
  17 + if (i < 0 || i >= size) {
  18 + return undefined;
  19 + }
  20 +
  21 + var first = str.charCodeAt(i);
  22 +
  23 + if (first >= 0xD800 && first <= 0xDBFF && size > i + 1) {
  24 + var second = str.charCodeAt(i + 1);
  25 +
  26 + if (second >= 0xDC00 && second <= 0xDFFF) {
  27 + return ((first - 0xD800) * 0x400) + second - 0xDC00 + 0x10000;
  28 + }
  29 + }
  30 +
  31 + return first;
  32 +};
  1 +The MIT License (MIT)
  2 +
  3 +Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
  4 +
  5 +Permission is hereby granted, free of charge, to any person obtaining a copy
  6 +of this software and associated documentation files (the "Software"), to deal
  7 +in the Software without restriction, including without limitation the rights
  8 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9 +copies of the Software, and to permit persons to whom the Software is
  10 +furnished to do so, subject to the following conditions:
  11 +
  12 +The above copyright notice and this permission notice shall be included in
  13 +all copies or substantial portions of the Software.
  14 +
  15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21 +THE SOFTWARE.
  1 +{
  2 + "_args": [
  3 + [
  4 + {
  5 + "raw": "code-point-at@^1.0.0",
  6 + "scope": null,
  7 + "escapedName": "code-point-at",
  8 + "name": "code-point-at",
  9 + "rawSpec": "^1.0.0",
  10 + "spec": ">=1.0.0 <2.0.0",
  11 + "type": "range"
  12 + },
  13 + "/Users/fzy/project/koa2_Sequelize_project/node_modules/string-width"
  14 + ]
  15 + ],
  16 + "_from": "code-point-at@>=1.0.0 <2.0.0",
  17 + "_id": "code-point-at@1.1.0",
  18 + "_inCache": true,
  19 + "_location": "/code-point-at",
  20 + "_nodeVersion": "4.6.1",
  21 + "_npmOperationalInternal": {
  22 + "host": "packages-12-west.internal.npmjs.com",
  23 + "tmp": "tmp/code-point-at-1.1.0.tgz_1478169780337_0.8445875702891499"
  24 + },
  25 + "_npmUser": {
  26 + "name": "sindresorhus",
  27 + "email": "sindresorhus@gmail.com"
  28 + },
  29 + "_npmVersion": "2.15.9",
  30 + "_phantomChildren": {},
  31 + "_requested": {
  32 + "raw": "code-point-at@^1.0.0",
  33 + "scope": null,
  34 + "escapedName": "code-point-at",
  35 + "name": "code-point-at",
  36 + "rawSpec": "^1.0.0",
  37 + "spec": ">=1.0.0 <2.0.0",
  38 + "type": "range"
  39 + },
  40 + "_requiredBy": [
  41 + "/string-width"
  42 + ],
  43 + "_resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz",
  44 + "_shasum": "0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77",
  45 + "_shrinkwrap": null,
  46 + "_spec": "code-point-at@^1.0.0",
  47 + "_where": "/Users/fzy/project/koa2_Sequelize_project/node_modules/string-width",
  48 + "author": {
  49 + "name": "Sindre Sorhus",
  50 + "email": "sindresorhus@gmail.com",
  51 + "url": "sindresorhus.com"
  52 + },
  53 + "bugs": {
  54 + "url": "https://github.com/sindresorhus/code-point-at/issues"
  55 + },
  56 + "dependencies": {},
  57 + "description": "ES2015 `String#codePointAt()` ponyfill",
  58 + "devDependencies": {
  59 + "ava": "*",
  60 + "xo": "^0.16.0"
  61 + },
  62 + "directories": {},
  63 + "dist": {
  64 + "shasum": "0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77",
  65 + "tarball": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz"
  66 + },
  67 + "engines": {
  68 + "node": ">=0.10.0"
  69 + },
  70 + "files": [
  71 + "index.js"
  72 + ],
  73 + "gitHead": "f8f21c8df2d40248fef1b36ca9076e59c0c34791",
  74 + "homepage": "https://github.com/sindresorhus/code-point-at#readme",
  75 + "keywords": [
  76 + "es2015",
  77 + "ponyfill",
  78 + "polyfill",
  79 + "shim",
  80 + "string",
  81 + "str",
  82 + "code",
  83 + "point",
  84 + "at",
  85 + "codepoint",
  86 + "unicode"
  87 + ],
  88 + "license": "MIT",
  89 + "maintainers": [
  90 + {
  91 + "name": "sindresorhus",
  92 + "email": "sindresorhus@gmail.com"
  93 + }
  94 + ],
  95 + "name": "code-point-at",
  96 + "optionalDependencies": {},
  97 + "readme": "# code-point-at [![Build Status](https://travis-ci.org/sindresorhus/code-point-at.svg?branch=master)](https://travis-ci.org/sindresorhus/code-point-at)\n\n> ES2015 [`String#codePointAt()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt) [ponyfill](https://ponyfill.com)\n\n\n## Install\n\n```\n$ npm install --save code-point-at\n```\n\n\n## Usage\n\n```js\nvar codePointAt = require('code-point-at');\n\ncodePointAt('🐴');\n//=> 128052\n\ncodePointAt('abc', 2);\n//=> 99\n```\n\n## API\n\n### codePointAt(input, [position])\n\n\n## License\n\nMIT © [Sindre Sorhus](https://sindresorhus.com)\n",
  98 + "readmeFilename": "readme.md",
  99 + "repository": {
  100 + "type": "git",
  101 + "url": "git+https://github.com/sindresorhus/code-point-at.git"
  102 + },
  103 + "scripts": {
  104 + "test": "xo && ava"
  105 + },
  106 + "version": "1.1.0"
  107 +}
  1 +# code-point-at [![Build Status](https://travis-ci.org/sindresorhus/code-point-at.svg?branch=master)](https://travis-ci.org/sindresorhus/code-point-at)
  2 +
  3 +> ES2015 [`String#codePointAt()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt) [ponyfill](https://ponyfill.com)
  4 +
  5 +
  6 +## Install
  7 +
  8 +```
  9 +$ npm install --save code-point-at
  10 +```
  11 +
  12 +
  13 +## Usage
  14 +
  15 +```js
  16 +var codePointAt = require('code-point-at');
  17 +
  18 +codePointAt('🐴');
  19 +//=> 128052
  20 +
  21 +codePointAt('abc', 2);
  22 +//=> 99
  23 +```
  24 +
  25 +## API
  26 +
  27 +### codePointAt(input, [position])
  28 +
  29 +
  30 +## License
  31 +
  32 +MIT © [Sindre Sorhus](https://sindresorhus.com)
  1 +Copyright (c) 2014, Rebecca Turner <me@re-becca.org>
  2 +
  3 +Permission to use, copy, modify, and/or distribute this software for any
  4 +purpose with or without fee is hereby granted, provided that the above
  5 +copyright notice and this permission notice appear in all copies.
  6 +
  7 +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  8 +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  9 +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  10 +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  11 +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  12 +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  13 +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  1 +# Console Control Strings
  2 +
  3 +A library of cross-platform tested terminal/console command strings for
  4 +doing things like color and cursor positioning. This is a subset of both
  5 +ansi and vt100. All control codes included work on both Windows & Unix-like
  6 +OSes, except where noted.
  7 +
  8 +## Usage
  9 +
  10 +```js
  11 +var consoleControl = require('console-control-strings')
  12 +
  13 +console.log(consoleControl.color('blue','bgRed', 'bold') + 'hi there' + consoleControl.color('reset'))
  14 +process.stdout.write(consoleControl.goto(75, 10))
  15 +```
  16 +
  17 +## Why Another?
  18 +
  19 +There are tons of libraries similar to this one. I wanted one that was:
  20 +
  21 +1. Very clear about compatibility goals.
  22 +2. Could emit, for instance, a start color code without an end one.
  23 +3. Returned strings w/o writing to streams.
  24 +4. Was not weighed down with other unrelated baggage.
  25 +
  26 +## Functions
  27 +
  28 +### var code = consoleControl.up(_num = 1_)
  29 +
  30 +Returns the escape sequence to move _num_ lines up.
  31 +
  32 +### var code = consoleControl.down(_num = 1_)
  33 +
  34 +Returns the escape sequence to move _num_ lines down.
  35 +
  36 +### var code = consoleControl.forward(_num = 1_)
  37 +
  38 +Returns the escape sequence to move _num_ lines righ.
  39 +
  40 +### var code = consoleControl.back(_num = 1_)
  41 +
  42 +Returns the escape sequence to move _num_ lines left.
  43 +
  44 +### var code = consoleControl.nextLine(_num = 1_)
  45 +
  46 +Returns the escape sequence to move _num_ lines down and to the beginning of
  47 +the line.
  48 +
  49 +### var code = consoleControl.previousLine(_num = 1_)
  50 +
  51 +Returns the escape sequence to move _num_ lines up and to the beginning of
  52 +the line.
  53 +
  54 +### var code = consoleControl.eraseData()
  55 +
  56 +Returns the escape sequence to erase everything from the current cursor
  57 +position to the bottom right of the screen. This is line based, so it
  58 +erases the remainder of the current line and all following lines.
  59 +
  60 +### var code = consoleControl.eraseLine()
  61 +
  62 +Returns the escape sequence to erase to the end of the current line.
  63 +
  64 +### var code = consoleControl.goto(_x_, _y_)
  65 +
  66 +Returns the escape sequence to move the cursor to the designated position.
  67 +Note that the origin is _1, 1_ not _0, 0_.
  68 +
  69 +### var code = consoleControl.gotoSOL()
  70 +
  71 +Returns the escape sequence to move the cursor to the beginning of the
  72 +current line. (That is, it returns a carriage return, `\r`.)
  73 +
  74 +### var code = consoleControl.beep()
  75 +
  76 +Returns the escape sequence to cause the termianl to beep. (That is, it
  77 +returns unicode character `\x0007`, a Control-G.)
  78 +
  79 +### var code = consoleControl.hideCursor()
  80 +
  81 +Returns the escape sequence to hide the cursor.
  82 +
  83 +### var code = consoleControl.showCursor()
  84 +
  85 +Returns the escape sequence to show the cursor.
  86 +
  87 +### var code = consoleControl.color(_colors = []_)
  88 +
  89 +### var code = consoleControl.color(_color1_, _color2_, _…_, _colorn_)
  90 +
  91 +Returns the escape sequence to set the current terminal display attributes
  92 +(mostly colors). Arguments can either be a list of attributes or an array
  93 +of attributes. The difference between passing in an array or list of colors
  94 +and calling `.color` separately for each one, is that in the former case a
  95 +single escape sequence will be produced where as in the latter each change
  96 +will have its own distinct escape sequence. Each attribute can be one of:
  97 +
  98 +* Reset:
  99 + * **reset** – Reset all attributes to the terminal default.
  100 +* Styles:
  101 + * **bold** – Display text as bold. In some terminals this means using a
  102 + bold font, in others this means changing the color. In some it means
  103 + both.
  104 + * **italic** – Display text as italic. This is not available in most Windows terminals.
  105 + * **underline** – Underline text. This is not available in most Windows Terminals.
  106 + * **inverse** – Invert the foreground and background colors.
  107 + * **stopBold** – Do not display text as bold.
  108 + * **stopItalic** – Do not display text as italic.
  109 + * **stopUnderline** – Do not underline text.
  110 + * **stopInverse** – Do not invert foreground and background.
  111 +* Colors:
  112 + * **white**
  113 + * **black**
  114 + * **blue**
  115 + * **cyan**
  116 + * **green**
  117 + * **magenta**
  118 + * **red**
  119 + * **yellow**
  120 + * **grey** / **brightBlack**
  121 + * **brightRed**
  122 + * **brightGreen**
  123 + * **brightYellow**
  124 + * **brightBlue**
  125 + * **brightMagenta**
  126 + * **brightCyan**
  127 + * **brightWhite**
  128 +* Background Colors:
  129 + * **bgWhite**
  130 + * **bgBlack**
  131 + * **bgBlue**
  132 + * **bgCyan**
  133 + * **bgGreen**
  134 + * **bgMagenta**
  135 + * **bgRed**
  136 + * **bgYellow**
  137 + * **bgGrey** / **bgBrightBlack**
  138 + * **bgBrightRed**
  139 + * **bgBrightGreen**
  140 + * **bgBrightYellow**
  141 + * **bgBrightBlue**
  142 + * **bgBrightMagenta**
  143 + * **bgBrightCyan**
  144 + * **bgBrightWhite**
  145 +
  1 +'use strict'
  2 +
  3 +// These tables borrowed from `ansi`
  4 +
  5 +var prefix = '\x1b['
  6 +
  7 +exports.up = function up (num) {
  8 + return prefix + (num || '') + 'A'
  9 +}
  10 +
  11 +exports.down = function down (num) {
  12 + return prefix + (num || '') + 'B'
  13 +}
  14 +
  15 +exports.forward = function forward (num) {
  16 + return prefix + (num || '') + 'C'
  17 +}
  18 +
  19 +exports.back = function back (num) {
  20 + return prefix + (num || '') + 'D'
  21 +}
  22 +
  23 +exports.nextLine = function nextLine (num) {
  24 + return prefix + (num || '') + 'E'
  25 +}
  26 +
  27 +exports.previousLine = function previousLine (num) {
  28 + return prefix + (num || '') + 'F'
  29 +}
  30 +
  31 +exports.horizontalAbsolute = function horizontalAbsolute (num) {
  32 + if (num == null) throw new Error('horizontalAboslute requires a column to position to')
  33 + return prefix + num + 'G'
  34 +}
  35 +
  36 +exports.eraseData = function eraseData () {
  37 + return prefix + 'J'
  38 +}
  39 +
  40 +exports.eraseLine = function eraseLine () {
  41 + return prefix + 'K'
  42 +}
  43 +
  44 +exports.goto = function (x, y) {
  45 + return prefix + y + ';' + x + 'H'
  46 +}
  47 +
  48 +exports.gotoSOL = function () {
  49 + return '\r'
  50 +}
  51 +
  52 +exports.beep = function () {
  53 + return '\x07'
  54 +}
  55 +
  56 +exports.hideCursor = function hideCursor () {
  57 + return prefix + '?25l'
  58 +}
  59 +
  60 +exports.showCursor = function showCursor () {
  61 + return prefix + '?25h'
  62 +}
  63 +
  64 +var colors = {
  65 + reset: 0,
  66 +// styles
  67 + bold: 1,
  68 + italic: 3,
  69 + underline: 4,
  70 + inverse: 7,
  71 +// resets
  72 + stopBold: 22,
  73 + stopItalic: 23,
  74 + stopUnderline: 24,
  75 + stopInverse: 27,
  76 +// colors
  77 + white: 37,
  78 + black: 30,
  79 + blue: 34,
  80 + cyan: 36,
  81 + green: 32,
  82 + magenta: 35,
  83 + red: 31,
  84 + yellow: 33,
  85 + bgWhite: 47,
  86 + bgBlack: 40,
  87 + bgBlue: 44,
  88 + bgCyan: 46,
  89 + bgGreen: 42,
  90 + bgMagenta: 45,
  91 + bgRed: 41,
  92 + bgYellow: 43,
  93 +
  94 + grey: 90,
  95 + brightBlack: 90,
  96 + brightRed: 91,
  97 + brightGreen: 92,
  98 + brightYellow: 93,
  99 + brightBlue: 94,
  100 + brightMagenta: 95,
  101 + brightCyan: 96,
  102 + brightWhite: 97,
  103 +
  104 + bgGrey: 100,
  105 + bgBrightBlack: 100,
  106 + bgBrightRed: 101,
  107 + bgBrightGreen: 102,
  108 + bgBrightYellow: 103,
  109 + bgBrightBlue: 104,
  110 + bgBrightMagenta: 105,
  111 + bgBrightCyan: 106,
  112 + bgBrightWhite: 107
  113 +}
  114 +
  115 +exports.color = function color (colorWith) {
  116 + if (arguments.length !== 1 || !Array.isArray(colorWith)) {
  117 + colorWith = Array.prototype.slice.call(arguments)
  118 + }
  119 + return prefix + colorWith.map(colorNameToCode).join(';') + 'm'
  120 +}
  121 +
  122 +function colorNameToCode (color) {
  123 + if (colors[color] != null) return colors[color]
  124 + throw new Error('Unknown color or style name: ' + color)
  125 +}
  1 +{
  2 + "_args": [
  3 + [
  4 + {
  5 + "raw": "console-control-strings@~1.1.0",
  6 + "scope": null,
  7 + "escapedName": "console-control-strings",
  8 + "name": "console-control-strings",
  9 + "rawSpec": "~1.1.0",
  10 + "spec": ">=1.1.0 <1.2.0",
  11 + "type": "range"
  12 + },
  13 + "/Users/fzy/project/koa2_Sequelize_project/node_modules/npmlog"
  14 + ]
  15 + ],
  16 + "_from": "console-control-strings@>=1.1.0 <1.2.0",
  17 + "_id": "console-control-strings@1.1.0",
  18 + "_inCache": true,
  19 + "_location": "/console-control-strings",
  20 + "_nodeVersion": "4.4.0",
  21 + "_npmOperationalInternal": {
  22 + "host": "packages-16-east.internal.npmjs.com",
  23 + "tmp": "tmp/console-control-strings-1.1.0.tgz_1466033396831_0.9470485949423164"
  24 + },
  25 + "_npmUser": {
  26 + "name": "iarna",
  27 + "email": "me@re-becca.org"
  28 + },
  29 + "_npmVersion": "3.9.2",
  30 + "_phantomChildren": {},
  31 + "_requested": {
  32 + "raw": "console-control-strings@~1.1.0",
  33 + "scope": null,
  34 + "escapedName": "console-control-strings",
  35 + "name": "console-control-strings",
  36 + "rawSpec": "~1.1.0",
  37 + "spec": ">=1.1.0 <1.2.0",
  38 + "type": "range"
  39 + },
  40 + "_requiredBy": [
  41 + "/gauge",
  42 + "/npmlog"
  43 + ],
  44 + "_resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz",
  45 + "_shasum": "3d7cf4464db6446ea644bf4b39507f9851008e8e",
  46 + "_shrinkwrap": null,
  47 + "_spec": "console-control-strings@~1.1.0",
  48 + "_where": "/Users/fzy/project/koa2_Sequelize_project/node_modules/npmlog",
  49 + "author": {
  50 + "name": "Rebecca Turner",
  51 + "email": "me@re-becca.org",
  52 + "url": "http://re-becca.org/"
  53 + },
  54 + "bugs": {
  55 + "url": "https://github.com/iarna/console-control-strings/issues"
  56 + },
  57 + "dependencies": {},
  58 + "description": "A library of cross-platform tested terminal/console command strings for doing things like color and cursor positioning. This is a subset of both ansi and vt100. All control codes included work on both Windows & Unix-like OSes, except where noted.",
  59 + "devDependencies": {
  60 + "standard": "^7.1.2",
  61 + "tap": "^5.7.2"
  62 + },
  63 + "directories": {
  64 + "test": "test"
  65 + },
  66 + "dist": {
  67 + "shasum": "3d7cf4464db6446ea644bf4b39507f9851008e8e",
  68 + "tarball": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz"
  69 + },
  70 + "files": [
  71 + "LICENSE",
  72 + "index.js"
  73 + ],
  74 + "gitHead": "722439b4998d2964ac3d3f9ec175c008aa9b7b4b",
  75 + "homepage": "https://github.com/iarna/console-control-strings#readme",
  76 + "keywords": [],
  77 + "license": "ISC",
  78 + "main": "index.js",
  79 + "maintainers": [
  80 + {
  81 + "name": "iarna",
  82 + "email": "me@re-becca.org"
  83 + }
  84 + ],
  85 + "name": "console-control-strings",
  86 + "optionalDependencies": {},
  87 + "readme": "# Console Control Strings\n\nA library of cross-platform tested terminal/console command strings for\ndoing things like color and cursor positioning. This is a subset of both\nansi and vt100. All control codes included work on both Windows & Unix-like\nOSes, except where noted.\n\n## Usage\n\n```js\nvar consoleControl = require('console-control-strings')\n\nconsole.log(consoleControl.color('blue','bgRed', 'bold') + 'hi there' + consoleControl.color('reset'))\nprocess.stdout.write(consoleControl.goto(75, 10))\n```\n\n## Why Another?\n\nThere are tons of libraries similar to this one. I wanted one that was:\n\n1. Very clear about compatibility goals.\n2. Could emit, for instance, a start color code without an end one.\n3. Returned strings w/o writing to streams.\n4. Was not weighed down with other unrelated baggage.\n\n## Functions\n\n### var code = consoleControl.up(_num = 1_)\n\nReturns the escape sequence to move _num_ lines up.\n\n### var code = consoleControl.down(_num = 1_)\n\nReturns the escape sequence to move _num_ lines down.\n\n### var code = consoleControl.forward(_num = 1_)\n\nReturns the escape sequence to move _num_ lines righ.\n\n### var code = consoleControl.back(_num = 1_)\n\nReturns the escape sequence to move _num_ lines left.\n\n### var code = consoleControl.nextLine(_num = 1_)\n\nReturns the escape sequence to move _num_ lines down and to the beginning of\nthe line.\n\n### var code = consoleControl.previousLine(_num = 1_)\n\nReturns the escape sequence to move _num_ lines up and to the beginning of\nthe line.\n\n### var code = consoleControl.eraseData()\n\nReturns the escape sequence to erase everything from the current cursor\nposition to the bottom right of the screen. This is line based, so it\nerases the remainder of the current line and all following lines.\n\n### var code = consoleControl.eraseLine()\n\nReturns the escape sequence to erase to the end of the current line.\n\n### var code = consoleControl.goto(_x_, _y_)\n\nReturns the escape sequence to move the cursor to the designated position. \nNote that the origin is _1, 1_ not _0, 0_.\n\n### var code = consoleControl.gotoSOL()\n\nReturns the escape sequence to move the cursor to the beginning of the\ncurrent line. (That is, it returns a carriage return, `\\r`.)\n\n### var code = consoleControl.beep()\n\nReturns the escape sequence to cause the termianl to beep. (That is, it\nreturns unicode character `\\x0007`, a Control-G.)\n\n### var code = consoleControl.hideCursor()\n\nReturns the escape sequence to hide the cursor.\n\n### var code = consoleControl.showCursor()\n\nReturns the escape sequence to show the cursor.\n\n### var code = consoleControl.color(_colors = []_)\n\n### var code = consoleControl.color(_color1_, _color2_, _…_, _colorn_)\n\nReturns the escape sequence to set the current terminal display attributes\n(mostly colors). Arguments can either be a list of attributes or an array\nof attributes. The difference between passing in an array or list of colors\nand calling `.color` separately for each one, is that in the former case a\nsingle escape sequence will be produced where as in the latter each change\nwill have its own distinct escape sequence. Each attribute can be one of:\n\n* Reset:\n * **reset** – Reset all attributes to the terminal default.\n* Styles:\n * **bold** – Display text as bold. In some terminals this means using a\n bold font, in others this means changing the color. In some it means\n both.\n * **italic** – Display text as italic. This is not available in most Windows terminals.\n * **underline** – Underline text. This is not available in most Windows Terminals.\n * **inverse** – Invert the foreground and background colors.\n * **stopBold** – Do not display text as bold.\n * **stopItalic** – Do not display text as italic.\n * **stopUnderline** – Do not underline text.\n * **stopInverse** – Do not invert foreground and background.\n* Colors:\n * **white**\n * **black**\n * **blue**\n * **cyan**\n * **green**\n * **magenta**\n * **red**\n * **yellow**\n * **grey** / **brightBlack**\n * **brightRed**\n * **brightGreen**\n * **brightYellow**\n * **brightBlue**\n * **brightMagenta**\n * **brightCyan**\n * **brightWhite**\n* Background Colors:\n * **bgWhite**\n * **bgBlack**\n * **bgBlue**\n * **bgCyan**\n * **bgGreen**\n * **bgMagenta**\n * **bgRed**\n * **bgYellow**\n * **bgGrey** / **bgBrightBlack**\n * **bgBrightRed**\n * **bgBrightGreen**\n * **bgBrightYellow**\n * **bgBrightBlue**\n * **bgBrightMagenta**\n * **bgBrightCyan**\n * **bgBrightWhite**\n\n",
  88 + "readmeFilename": "README.md",
  89 + "repository": {
  90 + "type": "git",
  91 + "url": "git+https://github.com/iarna/console-control-strings.git"
  92 + },
  93 + "scripts": {
  94 + "test": "standard && tap test/*.js"
  95 + },
  96 + "version": "1.1.0"
  97 +}
  1 +{
  2 + "asi": true,
  3 + "laxcomma": true,
  4 + "laxbreak": true,
  5 + "node": true,
  6 + "strict": false,
  7 + "es5": true
  8 +}
  1 +#IDE Support
  2 +.idea
  3 +
  4 +#Project
  5 +.lock-wscript
  6 +*.dylib
  7 +*.so
  8 +*.o
  9 +*.lo
  10 +*.Makefile
  11 +*.target.gyp.mk
  12 +build
  13 +Release
  14 +Debug
  15 +node_modules
  16 +Makefile.gyp
  17 +gyp-*-tool
  18 +.dirstamp
  19 +npm-debug.log
  1 +os:
  2 + - linux
  3 + - osx
  4 +sudo: false
  5 +language: cpp
  6 +addons:
  7 + apt:
  8 + sources:
  9 + - ubuntu-toolchain-r-test
  10 + packages:
  11 + - g++-4.8
  12 +env:
  13 + matrix:
  14 + - TRAVIS_NODE_VERSION="0.10"
  15 + - TRAVIS_NODE_VERSION="0.12"
  16 + - TRAVIS_NODE_VERSION="2"
  17 + - TRAVIS_NODE_VERSION="4.1"
  18 + - TRAVIS_NODE_VERSION="5.1"
  19 + - TRAVIS_NODE_VERSION="6"
  20 +
  21 +install:
  22 + - rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install $TRAVIS_NODE_VERSION
  23 + - if [[ $TRAVIS_OS_NAME == "linux" ]]; then export CXX=g++-4.8; fi
  24 + - $CXX --version
  25 + - PATH="`npm bin`:`npm bin -g`:$PATH"
  26 + # Node 0.8 comes with a too obsolete npm
  27 + - if [[ "`node --version`" =~ ^v0\.8\. ]]; then npm install -g npm@1.4.28 ; fi
  28 + # Install dependencies and build
  29 + - npm install
  30 +
  31 +script:
  32 + # Output useful info for debugging
  33 + - node --version
  34 + - npm --version
  35 + # Run tests
  36 + - npm test
  1 +2.2.0 / 2016-10-29
  2 +==================
  3 +
  4 +* [[`8fc355f276`](https://github.com/node-ffi/ffi/commit/8fc355f276)] - add libffi `version` string (Nathan Rajlich)
  5 +* [[`97d7ab12e6`](https://github.com/node-ffi/ffi/commit/97d7ab12e6)] - remove OS X 10.5 deployment target (Nathan Rajlich)
  6 +* [[`7a928f38b1`](https://github.com/node-ffi/ffi/commit/7a928f38b1)] - **test**: add a test case for [TooTallNate/ref#56](https://github.com/TooTallNate/ref/issues/56) (Nathan Rajlich)
  7 +
  8 +2.1.0 / 2016-08-03
  9 +==================
  10 +
  11 +* [[`a66fb8b282`](https://github.com/node-ffi/ffi/commit/a66fb8b282)] - rename History.md to CHANGELOG.md (Nathan Rajlich)
  12 +* [[`424d6b2278`](https://github.com/node-ffi/ffi/commit/424d6b2278)] - test node v6 with CI (Nathan Rajlich)
  13 +* [[`37dc33f10d`](https://github.com/node-ffi/ffi/commit/37dc33f10d)] - Move `errno` method implement to C++ side (Lee, SungUk)
  14 +* [[`f0547a7535`](https://github.com/node-ffi/ffi/commit/f0547a7535)] - **test**: use full URL to issue (Nathan Rajlich)
  15 +* [[`819c664605`](https://github.com/node-ffi/ffi/commit/819c664605)] - **appveyor, travis**: test node v5.1 (Nathan Rajlich)
  16 +* [[`b6e8dba046`](https://github.com/node-ffi/ffi/commit/b6e8dba046)] - remove benchmark files (Nathan Rajlich)
  17 +* [[`f5e445be91`](https://github.com/node-ffi/ffi/commit/f5e445be91)] - **test**: load Foundation first instead (Nathan Rajlich)
  18 +* [[`529ea78029`](https://github.com/node-ffi/ffi/commit/529ea78029)] - **travis**: remove iojs v3 (Nathan Rajlich)
  19 +* [[`c81ab1ed1e`](https://github.com/node-ffi/ffi/commit/c81ab1ed1e)] - **test**: load `Cocoa` lib for Obj-C tests (Nathan Rajlich)
  20 +* [[`829d7dac02`](https://github.com/node-ffi/ffi/commit/829d7dac02)] - **travis**: attempt to test "osx" (Nathan Rajlich)
  21 +* [[`979da99892`](https://github.com/node-ffi/ffi/commit/979da99892)] - **test**: fix hardcoded `strtoul()` bindings (Nathan Rajlich)
  22 +* [[`9cc558632c`](https://github.com/node-ffi/ffi/commit/9cc558632c)] - **test**: fix comment (Nathan Rajlich)
  23 +* [[`3d673ca2a1`](https://github.com/node-ffi/ffi/commit/3d673ca2a1)] - **test**: attempt to fix test 169 on Linux (Nathan Rajlich)
  24 +* [[`c2e5996d9d`](https://github.com/node-ffi/ffi/commit/c2e5996d9d)] - **test**: remove .only() (Nathan Rajlich)
  25 +* [[`1187b80f7b`](https://github.com/node-ffi/ffi/commit/1187b80f7b)] - **test**: add case for allowing Buffer backing store for "string" FFI argument (Nathan Rajlich)
  26 +* [[`3b09d1ac09`](https://github.com/node-ffi/ffi/commit/3b09d1ac09)] - **test**: remove semis (Nathan Rajlich)
  27 +* [[`74e29a17d0`](https://github.com/node-ffi/ffi/commit/74e29a17d0)] - **test**: whitespace fixes (Nathan Rajlich)
  28 +* [[`6551d4ab5b`](https://github.com/node-ffi/ffi/commit/6551d4ab5b)] - **appveyor**: test node v4.1 (Nathan Rajlich)
  29 +* [[`c0b64413fe`](https://github.com/node-ffi/ffi/commit/c0b64413fe)] - **travis**: test node v4.1 (Nathan Rajlich)
  30 +* [[`730bd4a92f`](https://github.com/node-ffi/ffi/commit/730bd4a92f)] - **travis**: drop "iojs-" prefix from version names (Nathan Rajlich)
  31 +* [[`0324f3be9c`](https://github.com/node-ffi/ffi/commit/0324f3be9c)] - test node v0.4 (Nathan Rajlich)
  32 +* [[`f3e393bb55`](https://github.com/node-ffi/ffi/commit/f3e393bb55)] - remove node v0.8 from testing matrices (Nathan Rajlich)
  33 +
  34 +2.0.0 / 2015-09-04
  35 +==================
  36 +
  37 + * update to "nan" v2, adds io.js v3 support
  38 + * replace "dlfcn-win32" with "simple-dlfcn-win32" (uses MIT license rather than LGPL, #226, @mcnameej)
  39 + * remove compiled binary file from libffi deps dir (#229, @fredericgermain)
  40 + * fix dynamic linking when locale is not English (#224, @unbornchikken)
  41 + * appveyor: test v0.8, io.js v2.5 and v3
  42 + * travis: test v0.8, and iojs v2.5 and v3
  43 + * package: add "license" field
  44 + * package: add Gábor to LICENSE and "contributors"
  45 + * package: move TooTallNate to "contributors" array
  46 +
  47 +1.3.2 / 2015-07-31
  48 +==================
  49 +
  50 + * package: made the nan dependency stricter (#217, @feldgendler)
  51 + * package: reflect the fact that the build fails for node <= 0.8 (#196, @addaleax)
  52 +
  53 +1.3.1 / 2015-04-16
  54 +==================
  55 +
  56 + * test: use `assert.throws()` for Obj-C test cases
  57 + * test: add case for #199 that covers callback and error propagation on non-libuv thread
  58 + * HandleScope issue fix for iojs v1.7+
  59 + * use Windows' native thread API, rather than libuv
  60 +
  61 +1.3.0 / 2015-03-22
  62 +==================
  63 +
  64 + * add appveyor.yml file for Windows testing
  65 + * add support for io.js >= v1.1.0 and node.js v0.12.x via nan
  66 + * avoid VS build error LNK2005
  67 + * package: allow any "debug" v2
  68 + * package: update github URLs for new repo location
  69 + * travis: don't test node v0.6, test v0.12
  70 + * now using libuv's pthread impl on Windows, removed `pthreads-win32` dep
  71 + * `dlfcn-win32` dep updated to fix process global symbols on Windows
  72 + * README: add appveyor build badge
  73 + * README: use SVG appveyor badge
  74 +
  75 +1.2.7 / 2014-07-06
  76 +==================
  77 +
  78 + * test: add test case for race condition in #153
  79 + * factorial: fix Windows build instructions
  80 + * example: turn factorial readme to Markdown
  81 + * example: add Windows libfactorial.dll compile command
  82 + * package: remove "expect.js" dev dependency
  83 + * test: remove final `expect.js` usage
  84 + * jshintrc: enable "laxbreak"
  85 + * travis: remove IRC notifications from Travis
  86 + * test: properly re-add Mocha's uncaught listeners
  87 + * test: add a try/catch test after the callback is GC'd
  88 + * src: fix race condition when callback is invoked from thread pool (@nikmikov, #154)
  89 + * change Node.js versions used on Travis CI for testing (@Mithgol, #151)
  90 + * use SVG to display Travis CI build testing status (@Mithgol, #149)
  91 +
  92 +1.2.6 / 2013-10-08
  93 +==================
  94 +
  95 + * just a minor documentation typo fix (Jason May, #126)
  96 + * example: fix "factorial" example on Windows (#127)
  97 + * package: add "keywords" section
  98 + * callback: store a reference to the CIF struct on the ffi closure Buffer instance (#125)
  99 +
  100 +1.2.5 / 2013-04-06
  101 +==================
  102 +
  103 + * type: make detecting "long" and "ulong" ffi_types work
  104 + * travis: don't test node v0.7.x, test node v0.10.x
  105 +
  106 +1.2.4 / 2013-02-18
  107 +==================
  108 +
  109 + * FreeBSD 32-bit support (Dave Osborne)
  110 + * libffi: don't build libffi as a "thin" archive (CentOS 5 support, #110)
  111 +
  112 +1.2.3 / 2012-12-20
  113 +==================
  114 +
  115 + * FreeBSD 64-bit support (Dave Osborne)
  116 +
  117 +1.2.2 / 2012-12-15
  118 +==================
  119 +
  120 + * fix nasty bug in async FFI'd function on node v0.9.x
  121 +
  122 +1.2.1 / 2012-12-15
  123 +==================
  124 +
  125 + * add node >= v0.9.4 support
  126 +
  127 +1.2.0 / 2012-10-13
  128 +==================
  129 +
  130 + * type: full support for "ref-array" arguments and return types
  131 + * type: add basic support for basic ref types without a `ffi_type` prop set
  132 + * don't call the "ref()" function on passed in arguments
  133 + * libffi: fix unused variable warnings
  134 + * add `Function` "type" for functions/callbacks that accept/return C Functions
  135 + * dynamic_library: use RTLD_LAZY by default
  136 + * export all the RTLD_* symbols from the native binding
  137 + * foreign_function: better error messages when a type's "set()" function throws
  138 + * callback: make catching callbacks that throw JS exceptions work as expected
  139 + * callback: more meaningful error message when a type's "set()" function throws
  140 + * callback: fix pointer return values
  141 +
  142 +1.1.3 / 2012-09-25
  143 +==================
  144 +
  145 + * callback: use `IsEmpty()` instead of an explicit NULL check
  146 + * test: use "bindings" to load the bindings for the variadic tests
  147 + * ffi: use HandleScope in WrapPointer() (fixes ffi calls in a tight loop, see #74)
  148 + * test: fix typo in test name
  149 + * libffi: disable the C4267 implicit conversion warnings on Windows
  150 + * libffi: remove "as.bat" from the gyp file
  151 +
  152 +1.1.2 / 2012-09-16
  153 +==================
  154 +
  155 + * callback: throw an Error if the callback function has been garbage collected
  156 + * test: 100% tests passing on Windows!
  157 +
  158 +1.1.1 / 2012-09-16
  159 +==================
  160 +
  161 + * libffi: define "FFI_MMAP_EXEC_WRIT" on OS X (#71)
  162 + * added a new test case that calls a callback function directly (#72)
  163 +
  164 +1.1.0 / 2012-09-11
  165 +==================
  166 +
  167 + * properly "gyp-ify" libffi
  168 + - added "libffi.gyp"
  169 + - no more "hacks" in binding.gyp
  170 + - no need for MozillaBuild on Windows anymore!
  171 +
  172 +1.0.7 / 2012-08-03
  173 +==================
  174 +
  175 + * export `FFI_FIRST_ABI`
  176 + * export abi_enum values for ARM processors (100% tests passing on Raspberry Pi!)
  177 +
  178 +1.0.6 / 2012-07-22
  179 +==================
  180 +
  181 + * VariadicForeignFunction: apply a tweak to prevent false positives on ffi id's
  182 +
  183 +1.0.5 / 2012-07-22
  184 +==================
  185 +
  186 + * DynamicLibrary: use 'string' instead of "char *"
  187 + * DynamicLibrary: set the "name" property of the returned Buffer when get() is called
  188 + * test: add some "DynamicLibrary" tests
  189 + * VariadicForeignFunction: quick hack fix for the key caching name collision
  190 +
  191 +1.0.4 / 2012-07-12
  192 +==================
  193 +
  194 + * exit early when not compiling from within a MozillaBuild window on Windows
  195 +
  196 +1.0.3 / 2012-07-9
  197 +=================
  198 +
  199 + * refactor the README
  200 + * fix deprecation warning for using the `Utf8String` type (renamed to `CString`)
  201 + * remove circular `require()` calls (Justin Freitag)
  202 + * use the node-gyp `--directory` flag for `npm test` command
  203 +
  204 +1.0.2 / 2012-06-20
  205 +==================
  206 +
  207 + * Fix Windows build (32-bit at least). Fixes #51.
  208 +
  209 +1.0.1 / 2012-06-13
  210 +==================
  211 +
  212 + * Refactor the variadic function generator to allow for an overridden "returnType"
  213 +
  214 +1.0.0 / 2012-05-31
  215 +==================
  216 +
  217 + * Add a `VariadicForeignFunction` function for vararg C functions
  218 + * Various cleanup
  219 + * Don't export the native bindings (`ffi.Bindings` is gone)
  220 + * Use the `ref()` function when available, then fall back to `ref.alloc()`
  221 + * Add a few more tests
  222 +
  223 +1.0.0-alpha1 / 2012-05-29
  224 +=========================
  225 +
  226 + * Readme improvements
  227 + * Node >= v0.7.9 compatability
  228 +
  229 +1.0.0-alpha / 2012-05-25
  230 +========================
  231 +
  232 + * Alpha release of v1.0.0
  233 +
  234 +< 1.0.0
  235 +=======
  236 +
  237 + * Prehistoric: see `git log`
  1 +Copyright (c) 2009-2011 Richard "Rick" W. Branson
  2 +Copyright (c) 2012-2014 Nathan Rajlich, Richard "Rick" W. Branson
  3 +Copyright (c) 2015 Nathan Rajlich, Richard "Rick" W. Branson, Gabor Mezo
  4 +
  5 +Permission is hereby granted, free of charge, to any person obtaining a copy
  6 +of this software and associated documentation files (the "Software"), to
  7 +deal in the Software without restriction, including without limitation the
  8 +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9 +sell copies of the Software, and to permit persons to whom the Software is
  10 +furnished to do so, subject to the following conditions:
  11 +
  12 +The above copyright notice and this permission notice shall be included in
  13 +all copies or substantial portions of the Software.
  14 +
  15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20 +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21 +IN THE SOFTWARE.
  1 +node-ffi
  2 +========
  3 +### Node.js Foreign Function Interface
  4 +[![Build Status](https://travis-ci.org/node-ffi/node-ffi.svg?branch=master)](https://travis-ci.org/node-ffi/node-ffi)
  5 +[![Build Status](https://ci.appveyor.com/api/projects/status/n81apam1igfw8491?svg=true)](https://ci.appveyor.com/project/TooTallNate/node-ffi)
  6 +
  7 +`node-ffi` is a Node.js addon for loading and calling dynamic libraries using
  8 +pure JavaScript. It can be used to create bindings to native libraries without
  9 +writing any C++ code.
  10 +
  11 +It also simplifies the augmentation of node.js with C code as it takes care of
  12 +handling the translation of types across JavaScript and C, which can add reams
  13 +of boilerplate code to your otherwise simple C. See the `example/factorial`
  14 +for an example of this use case.
  15 +
  16 +**WARNING**: node-ffi assumes you know what you're doing. You can pretty easily
  17 +create situations where you will segfault the interpreter and unless you've got
  18 +C debugger skills, you probably won't know what's going on.
  19 +
  20 +Example
  21 +-------
  22 +
  23 +``` js
  24 +var ffi = require('ffi');
  25 +
  26 +var libm = ffi.Library('libm', {
  27 + 'ceil': [ 'double', [ 'double' ] ]
  28 +});
  29 +libm.ceil(1.5); // 2
  30 +
  31 +// You can also access just functions in the current process by passing a null
  32 +var current = ffi.Library(null, {
  33 + 'atoi': [ 'int', [ 'string' ] ]
  34 +});
  35 +current.atoi('1234'); // 1234
  36 +```
  37 +
  38 +For a more detailed introduction, see the [node-ffi tutorial page][tutorial].
  39 +
  40 +Requirements
  41 +------------
  42 +
  43 + * Linux, OS X, Windows, or Solaris.
  44 + * `libffi` comes bundled with node-ffi; it does *not* need to be installed on your system.
  45 + * The current version is tested to run on node v0.6, v0.8, v0.9 and v0.10.
  46 +
  47 +Installation
  48 +------------
  49 +
  50 +Make sure you've installed all the [necessary build
  51 +tools](https://github.com/TooTallNate/node-gyp#installation) for your platform,
  52 +then invoke:
  53 +
  54 +``` bash
  55 +$ npm install ffi
  56 +```
  57 +
  58 +Source Install / Manual Compilation
  59 +-----------------------------------
  60 +
  61 +To compile from source it's easiest to use
  62 +[`node-gyp`](https://github.com/TooTallNate/node-gyp):
  63 +
  64 +``` bash
  65 +$ npm install -g node-gyp
  66 +```
  67 +
  68 +Now you can compile `node-ffi`:
  69 +
  70 +``` bash
  71 +$ git clone git://github.com/node-ffi/node-ffi.git
  72 +$ cd node-ffi
  73 +$ node-gyp rebuild
  74 +```
  75 +
  76 +Types
  77 +-----
  78 +
  79 +The types that you specify in function declarations correspond to ref's types
  80 +system. So [see its docs][ref-types] for
  81 +a reference if you are unfamiliar.
  82 +
  83 +V8 and 64-bit Types
  84 +-------------------
  85 +
  86 +Internally, V8 stores integers that will fit into a 32-bit space in a 32-bit
  87 +integer, and those that fall outside of this get put into double-precision
  88 +floating point numbers. This is problematic because FP numbers are imprecise.
  89 +To get around this, the methods in node-ffi that deal with 64-bit integers return
  90 +strings and can accept strings as parameters.
  91 +
  92 +Call Overhead
  93 +-------------
  94 +
  95 +There is non-trivial overhead associated with FFI calls. Comparing a hard-coded
  96 +binding version of `strtoul()` to an FFI version of `strtoul()` shows that the
  97 +native hard-coded binding is orders of magnitude faster. So don't just use the
  98 +C version of a function just because it's faster. There's a significant cost in
  99 +FFI calls, so make them worth it.
  100 +
  101 +License
  102 +-------
  103 +
  104 +MIT License. See the `LICENSE` file.
  105 +
  106 +[v1apichanges]: https://github.com/node-ffi/node-ffi/wiki/API-changes-from-v0.x-to-v1.x
  107 +[tutorial]: https://github.com/node-ffi/node-ffi/wiki/Node-FFI-Tutorial
  108 +[ref-types]: https://github.com/TooTallNate/ref#built-in-types
  1 +# http://www.appveyor.com/docs/appveyor-yml
  2 +
  3 +# Test against these versions of Node.js.
  4 +environment:
  5 + # Visual Studio Version
  6 + MSVS_VERSION: 2013
  7 + # Test against these versions of Node.js and io.js
  8 + matrix:
  9 + # node.js
  10 + - nodejs_version: "0.10"
  11 + - nodejs_version: "0.12"
  12 + # io.js
  13 + - nodejs_version: "2"
  14 + - nodejs_version: "3.2"
  15 + - nodejs_version: "4.1"
  16 + - nodejs_version: "5.1"
  17 + - nodejs_version: "6"
  18 +
  19 +platform:
  20 + - x86
  21 + - x64
  22 +
  23 +# Install scripts. (runs after repo cloning)
  24 +install:
  25 + # Get the latest stable version of Node 0.STABLE.latest
  26 + - ps: if($env:nodejs_version -eq "0.8") {Install-Product node $env:nodejs_version}
  27 + - ps: if($env:nodejs_version -ne "0.8") {Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version)}
  28 + # Node 0.8 comes with a too obsolete npm
  29 + - IF %nodejs_version% == 0.8 (npm install -g npm@1.4.28)
  30 + # Install latest NPM only for node.js versions until built in node-gyp adds io.js support
  31 + # Update is required for node.js 0.8 because built in npm(node-gyp) does not know VS2013
  32 + - IF %nodejs_version% LSS 1 (npm install -g npm@2)
  33 + - IF %nodejs_version% LSS 1 set PATH=%APPDATA%\npm;%PATH%
  34 + # Typical npm stuff.
  35 + - npm install --msvs_version=%MSVS_VERSION%
  36 +
  37 +# Post-install test scripts.
  38 +test_script:
  39 + # Output useful info for debugging.
  40 + - node --version
  41 + - npm --version
  42 + # run tests
  43 + - npm test
  44 +
  45 +# Don't actually build.
  46 +build: off
  47 +
  48 +# Set build version format here instead of in the admin panel.
  49 +version: "{build}"
  1 +{
  2 + 'targets': [
  3 + {
  4 + 'target_name': 'ffi_bindings',
  5 + 'sources': [
  6 + 'src/ffi.cc'
  7 + , 'src/callback_info.cc'
  8 + , 'src/threaded_callback_invokation.cc'
  9 + ],
  10 + 'include_dirs': [
  11 + '<!(node -e "require(\'nan\')")'
  12 + ],
  13 + 'dependencies': [
  14 + 'deps/libffi/libffi.gyp:ffi'
  15 + ],
  16 + 'conditions': [
  17 + ['OS=="win"', {
  18 + 'sources': [
  19 + 'src/win32-dlfcn.cc'
  20 + ],
  21 + }],
  22 + ['OS=="mac"', {
  23 + 'xcode_settings': {
  24 + 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
  25 + 'OTHER_CFLAGS': [
  26 + '-ObjC++'
  27 + ]
  28 + },
  29 + 'libraries': [
  30 + '-lobjc'
  31 + ],
  32 + }]
  33 + ]
  34 + }
  35 + ]
  36 +}
  1 +.libs
  2 +.deps
  3 +*.o
  4 +*.lo
  5 +.dirstamp
  6 +*.la
  7 +*.pdb
  8 +*.obj
  9 +Makefile
  10 +config.log
  11 +config.status
  12 +*~
  13 +libffi.pc
  14 +libtool
  15 +stamp-h1
  16 +libffi*gz
  17 +autom4te.cache
此 diff 太大无法显示。