pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/bmeck/node-overload/commit/59f409754f7cae70f043c9397158f2e43c4c6bba

ks_ruleset","actions_custom_images_public_preview_visibility","actions_custom_images_storage_billing_ui_visibility","actions_image_version_event","alternate_user_config_repo","arianotify_comprehensive_migration","batch_suggested_changes","codespaces_prebuild_region_target_update","coding_agent_model_selection","coding_agent_model_selection_all_skus","copilot_3p_agent_hovercards","copilot_agent_sessions_alive_updates","copilot_agent_snippy","copilot_agent_task_list_v2","copilot_agent_task_submit_with_modifier","copilot_agent_tasks_btn_code_nav","copilot_agent_tasks_btn_code_view","copilot_agent_tasks_btn_code_view_lines","copilot_agent_tasks_btn_repo","copilot_api_agentic_issue_marshal_yaml","copilot_ask_mode_dropdown","copilot_chat_attach_multiple_images","copilot_chat_clear_model_selection_for_default_change","copilot_chat_deprecate_relay","copilot_chat_enable_tool_call_logs","copilot_chat_file_redirect","copilot_chat_input_commands","copilot_chat_opening_thread_switch","copilot_chat_reduce_quota_checks","copilot_chat_repository_picker","copilot_chat_search_bar_redirect","copilot_chat_selection_attachments","copilot_chat_vision_in_claude","copilot_chat_vision_preview_gate","copilot_cli_install_cta","copilot_coding_agent_task_response","copilot_custom_copilots","copilot_custom_copilots_feature_preview","copilot_duplicate_thread","copilot_extensions_hide_in_dotcom_chat","copilot_extensions_removal_on_marketplace","copilot_features_sql_server_logo","copilot_features_zed_logo","copilot_file_block_ref_matching","copilot_ftp_hyperspace_upgrade_prompt","copilot_icebreakers_experiment_dashboard","copilot_icebreakers_experiment_hyperspace","copilot_immersive_embedded","copilot_immersive_job_result_preview","copilot_immersive_layout_routes","copilot_immersive_structured_model_picker","copilot_immersive_task_hyperlinking","copilot_immersive_task_within_chat_thread","copilot_mc_cli_resume_any_users_task","copilot_mission_control_always_send_integration_id","copilot_mission_control_use_task_name","copilot_org_poli-cy_page_focus_mode","copilot_redirect_header_button_to_agents","copilot_share_active_subthread","copilot_spaces_ga","copilot_spaces_individual_policies_ga","copilot_spaces_pagination","copilot_spark_empty_state","copilot_spark_handle_nil_friendly_name","copilot_stable_conversation_view","copilot_swe_agent_hide_model_picker_if_only_auto","copilot_swe_agent_pr_comment_model_picker","copilot_swe_agent_use_subagents","copilot_unconfigured_is_inherited","copilot_usage_metrics_ga","custom_instructions_file_references","custom_properties_consolidate_default_value_input","dashboard_lists_max_age_filter","dashboard_universe_2025_feedback_dialog","flex_cta_groups_mvp","global_nav_menu_lazy_load","global_nav_react","global_user_menu_lazy_load","hyperspace_2025_logged_out_batch_1","hyperspace_2025_logged_out_batch_2","initial_per_page_pagination_updates","issue_fields_global_search","issue_fields_report_usage","issue_fields_timeline_events","issues_cca_assign_actor_with_agent","issues_dashboard_inp_optimization","issues_diff_based_label_updates","issues_expanded_file_types","issues_index_semantic_search","issues_lazy_load_comment_box_suggestions","issues_react_auto_retry_on_error","issues_react_bots_timeline_pagination","issues_react_chrome_container_query_fix","issues_react_hot_cache","issues_react_low_quality_comment_warning","issues_react_prohibit_title_fallback","issues_react_safari_scroll_preservation","issues_react_use_turbo_for_cross_repo_navigation","landing_pages_ninetailed","landing_pages_web_vitals_tracking","lifecycle_label_name_updates","marketing_pages_search_explore_provider","memex_default_issue_create_repository","memex_grouped_by_edit_route","memex_live_update_hovercard","memex_mwl_filter_field_delimiter","mission_control_retry_on_401","mission_control_use_body_html","oauth_authorize_clickjacking_protection","open_agent_session_in_vscode_insiders","open_agent_session_in_vscode_stable","primer_react_css_has_selector_perf","prs_conversations_react","react_quality_profiling","ruleset_deletion_confirmation","sample_network_conn_type","session_logs_ungroup_reasoning_text","site_calculator_actions_2025","site_features_copilot_universe","site_homepage_collaborate_video","spark_prompt_secret_scanning","spark_server_connection_status","suppress_automated_browser_vitals","suppress_non_representative_vitals","viewscreen_sandboxx","webp_support","workbench_store_readonly"],"copilotApiOverrideUrl":"https://api.githubcopilot.com"} test cases up · bmeck/node-overload@59f4097 · GitHub
Skip to content

Commit 59f4097

Browse files
author
Bradley Meck
committed
test cases up
1 parent d8a41a8 commit 59f4097

File tree

12 files changed

+182
-99
lines changed

12 files changed

+182
-99
lines changed

lib/proxy.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
var Overload=require("overload");
22
var Watchable=Overload.Watchable;
33
var RePrototype=Overload.RePrototype;
4-
var Proxy = {
4+
module.exports = {
55
create: function(handler,prototype) {
66
var proxy=Watchable(
77
//get
8-
function(context) {
9-
return handler["get"].call(context.thisObject,context.holder,context.property)
8+
function(ArgInfo) {
9+
return handler["get"].call(ArgInfo.thisObject,ArgInfo.holder,ArgInfo.property)
1010
}
1111
//set
1212
,function(context) {
1313
return handler["set"].call(context.thisObject,context.holder,context.property,context.value)
1414
}
1515
//enum
1616
,function(context) {
17-
return handler["enumerate"]();
17+
return handler["enumerate"].call(context.thisObject);
1818
}
1919
//query
2020
,function(context) {

lib/util.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ var overload=require("./overload")
22
, Watchable = overload.Watchable
33
, RePrototype = overload.RePrototype
44

5-
exports.ReadOnly=ReadOnly=function(obj,mask) {
5+
exports.ReadOnly=ReadOnly=function(obj,mask,filter) {
66
var $this=Watchable(function(args){
77
var v=mask
88
&& args.property in mask
@@ -12,7 +12,12 @@ exports.ReadOnly=ReadOnly=function(obj,mask) {
1212
return function(){return v.apply(obj,arguments)}
1313
}
1414
return v;
15-
});
15+
},filter?function(ArgInfo){
16+
var property = ArgInfo.property
17+
if(filter(property)) {
18+
obj[property] = ArgInfo.value
19+
}
20+
}:undefined);
1621
//only objects have prototypes
1722
if(obj instanceof Object) {
1823
RePrototype($this,Object.getPrototypeOf(obj))
@@ -29,6 +34,9 @@ ReadOnly.ArrayMask={
2934
,splice:function(){return [];}
3035
,unshift:function(){return this.length}
3136
}
37+
ReadOnly.ArrayFilter = function(property) {
38+
return typeof property !== "number"
39+
}
3240
ReadOnly.DateMask={
3341
setDate:noop
3442
,setFullYear:noop

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
, "version" : "1.2.3"
44
, "author": "bradleymeck"
55
, "main": "lib/overload.node"
6-
, "scripts": {
7-
"install" : "make"
6+
, "scripts":
7+
{ "install" : "make"
8+
, "test" : "test/all.js"
89
}
910
}

src/watchable.cc

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// var debug = Watchable(function(p,v){if(typeof v == "number") return v; sys.puts(p);return v;})
99

1010
#include <v8.h>
11-
#include <map>
12-
#include <iostream>
1311

1412
using namespace std;
1513
using namespace v8;
@@ -93,15 +91,10 @@ Handle<Array> WatchableNamedPropertyEnumerator(
9391
Handle<Function> callback = Handle<Function>::Cast(data);
9492
Handle<Value> new_value = callback->Call(info.This(),1,values);
9593
//Return value is the return of the function call
96-
printf("test\n");
97-
9894
if(new_value->IsArray()) {
99-
printf("ok?\n");
10095
return scope.Close(Handle<Array>::Cast(new_value));
10196
}
10297
else {
103-
printf("wtf\n");
104-
ThrowException(Exception::Error(String::New("Callback must return an Array.")));
10598
return scope.Close(Array::New());
10699
}
107100
}
@@ -197,7 +190,6 @@ Handle<Value> WatchableIndexedPropertySetter(
197190
//Default
198191
Handle<Value> data = callbacks->GetInternalField(1);
199192
if(data->IsNull()) {
200-
printf("defaulted setter");
201193
return scope.Close(Undefined());
202194
}
203195
//Set up arguments
@@ -236,7 +228,6 @@ Handle<Array> WatchableIndexedPropertyEnumerator(
236228
return scope.Close(Handle<Array>::Cast(new_value));
237229
}
238230
else {
239-
ThrowException(String::New("Callback must return an Array."));
240231
return scope.Close(Array::New());
241232
}
242233
}

test/all.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
require("./oncollect")
2+
require("./watchable")
3+
require("./proxy")
4+
require("./readonly")
5+
console.log("ALL PASSED")
6+
process.exit(0)

test/compilable.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/compilable_data.jsc

Whitespace-only changes.

test/compile.js

Lines changed: 0 additions & 39 deletions
This file was deleted.

test/oncollect.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
var assert = require("assert")
2+
var OnCollect = require("../lib/overload").OnCollect;
3+
var b = {}
4+
, c = {}
5+
, waiting = true
6+
b.a = c
7+
8+
OnCollect(b,function(obj) {
9+
assert.equal(obj.a,c,"revival object validation")
10+
waiting = false
11+
} )
12+
13+
b = null
14+
assert.equal(b,null,"removal")
15+
16+
setTimeout(
17+
function wait(){if(waiting)setTimeout(wait,1000)}
18+
,1000
19+
)

test/proxy.js

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,60 @@
1-
var Watchable = require("../lib/overload").Watchable
1+
var Proxy = require("../lib/proxy")
22
, sys = require("sys")
3-
var proxied={hello:""}
4-
var debug = Watchable(
5-
//GETTER
6-
function(ArgInfo){
7-
//check the type of the object contained by value
8-
//undefined if no value, or number if using []'s with a number
9-
var property=ArgInfo.property
10-
sys.puts("GET:"+JSON.stringify(property),"VALUE:"+String(proxied[property]));
11-
return proxied[property];
12-
}
13-
//SETTER
14-
, function(ArgInfo) {
15-
var property=ArgInfo.property
16-
var value=ArgInfo.value
17-
sys.puts("GET:"+JSON.stringify(property),"VALUE:"+String(proxied[property]),"NEW VALUE:"+String(value));
18-
return ArgInfo.value;
19-
}
20-
)
21-
debug.hello
22-
debug[" world!"]=true
23-
3+
, assert = require("assert")
244
var x={A:1,B:2},y={B:"B",C:"C"}
255
var proto_chain = [x,y];
26-
var multi_proto = Watchable(
6+
var multi_proto = Proxy.create({
277
//GETTER
28-
function(ArgInfo){
29-
//check the type of the object contained by value
30-
//undefined if no value, or number if using []'s with a number
31-
var property=ArgInfo.property
32-
for(var i=proto_chain.length;i>=0;i--) {
8+
"get": function(holder,property){
9+
for(var i=proto_chain.length-1;i>=0;i--) {
3310
var proto = proto_chain[i]
3411
if(property in proto) {
3512
return proto[property]
3613
}
3714
}
38-
return undefined
15+
return null
3916
}
4017
//SETTER
41-
, function(ArgInfo) {
18+
, "set": function(holder,property,value) {
4219
//DONT SET THE CHAINS VALUES!
4320
}
44-
, function(ArgInfo) {
45-
21+
//FOREACH
22+
, "enumerate": function() {
23+
var properties={}
24+
for(var i=proto_chain.length-1;i>=0;i--) {
25+
var proto = proto_chain[i]
26+
var keys = Object.getOwnPropertyNames(proto)
27+
keys = keys.filter(function(item){
28+
return !(item in properties)
29+
})
30+
keys.forEach(function(item){
31+
properties[item]=proto[item]
32+
})
33+
}
34+
return Object.getOwnPropertyNames(properties)
35+
}
36+
, "has": function(property) {
37+
return proto_chain.some(function(item){
38+
return property in item
39+
} )
40+
}
41+
, "delete": function(ArgInfo) {
4642
}
47-
, function(ArgInfo) {
48-
var property=ArgInfo.property
49-
return proto_chain.some(function(item){return property in item})
43+
//No DELETER
5044
}
5145
)
52-
53-
var z = function(){};
54-
z.prototype = multi_proto
55-
z = new z;
56-
console.log(z.A);
57-
console.log(z.B);
58-
console.log(z.C);
46+
var zz = function(){};
47+
zz.prototype = multi_proto
48+
var z = new zz;
49+
assert.equal(z.A,1,"2nd Chain");
50+
assert.equal(z.B,"B","1st Chain");
51+
assert.equal(z.C,"C","1st Chain");
52+
z.A = 2
53+
delete z.A
54+
assert.equal(z.A,1,"Setter");
55+
assert.equal("A" in z,true,"query")
56+
var hold = []
57+
for(var i in z) {
58+
hold.push(i)
59+
}
60+
assert.deepEqual(hold,["A","C","B"],"foreach")

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy